MathUtils Namespace Reference


Functions

bool calcBarycentricCoordinates (double x, double y, Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result)
 Calculates the barycentric coordinates of a point (x,y) with respect to p1, p2, p3 and stores the three barycentric coordinates in 'result'.
bool BarycentricToXY (double u, double v, double w, Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result)
double calcBernsteinPoly (int n, int i, double t)
 calculates the value of a Bernstein polynomial
double cFDerBernsteinPoly (int n, int i, double t)
 calculates the first derivative of a Bernstein polynomial with respect to the parameter t
double calcCubicHermitePoly (int n, int i, double t)
 calculates the value of a cubic Hermite polynomial
double cFDerCubicHermitePoly (int n, int i, double t)
 calculates the first derivative of a cubic Hermite polynomial with respect to the parameter t
bool circumcenter (Point3D *p1, Point3D *p2, Point3D *p3, Point3D *result)
 Calculates the center of the circle passing through p1, p2 and p3.
double distPointFromLine (Point3D *thepoint, Point3D *p1, Point3D *p2)
 Calculates the (2 dimensional) distance from 'thepoint' to the line defined by p1 and p2.
int faculty (int n)
 faculty function
bool inCircle (Point3D *testp, Point3D *p1, Point3D *p2, Point3D *p3)
 Tests, wheter 'testp' is inside the circle through 'p1', 'p2' and 'p3'.
bool inDiametral (Point3D *p1, Point3D *p2, Point3D *point)
 Tests, whether 'point' is inside the diametral circle through 'p1' and 'p2'.
double leftOf (Point3D *thepoint, Point3D *p1, Point3D *p2)
 Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.
bool lineIntersection (Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
 Returns true, if line1 (p1 to p2) and line2 (p3 to p4) intersect.
bool lineIntersection (Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4, Point3D *intersection_point)
 Returns true, if line1 (p1 to p2) and line2 (p3 to p4) intersect.
int lower (int n, int i)
 lower function
double max (double x, double y)
 returns the maximum of two doubles or the first argument if both are equal
double min (double x, double y)
 returns the minimum of two doubles or the first argument if both are equal
double power (double a, int b)
 power function for integer coefficients
double triArea (Point3D *pa, Point3D *pb, Point3D *pc)
 returns the area of a triangle.
bool derVec (const Vector3D *v1, const Vector3D *v2, Vector3D *result, double x, double y)
 Calculates the z-component of a vector with coordinates 'x' and 'y'which is in the same tangent plane as the tangent vectors 'v1' and 'v2'.
double crossVec (Point3D *first, Vector3D *vec1, Point3D *second, Vector3D *vec2)
 Calculates the intersection of the two vectors vec1 and vec2, which start at first(vec1) and second(vec2) end.
bool normalLeft (Vector3D *v1, Vector3D *result, double length)
 Assigns the vector 'result', which is normal to the vector 'v1', on the left side of v1 and has length 'length'.
bool normalRight (Vector3D *v1, Vector3D *result, double length)
 Assigns the vector 'result', which is normal to the vector 'v1', on the right side of v1 and has length 'length'.
void normalFromPoints (Point3D *p1, Point3D *p2, Point3D *p3, Vector3D *vec)
 Calculates the normal vector of the plane through the points p1, p2 and p3 and assigns the result to vec.
bool pointInsideTriangle (double x, double y, Point3D *p1, Point3D *p2, Point3D *p3)
 Returns true, if the point with coordinates x and y is inside (or at the edge) of the triangle p1,p2,p3 and false, if it is outside.
bool normalMinDistance (Vector3D *tangent, Vector3D *target, Vector3D *result)
 Calculates a Vector orthogonal to 'tangent' with length 1 and closest possible to result.
double planeTest (Point3D *test, Point3D *pt1, Point3D *pt2, Point3D *pt3)
 Tests, if 'test' is in the same plane as 'p1', 'p2' and 'p3' and returns the z-difference from the plane to 'test.
double angle (Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
 Calculates the angle between two segments (in 2 dimension, z-values are ignored).


Function Documentation

double MathUtils::angle ( Point3D p1,
Point3D p2,
Point3D p3,
Point3D p4 
)

Calculates the angle between two segments (in 2 dimension, z-values are ignored).

Referenced by DL_Dxf::addMText(), QgsNorthArrowPlugin::calculateNorthDirection(), DL_Dxf::handleHatchData(), and Builder::print_shpObjects().

bool MathUtils::BarycentricToXY ( double  u,
double  v,
double  w,
Point3D p1,
Point3D p2,
Point3D p3,
Point3D result 
)

bool MathUtils::calcBarycentricCoordinates ( double  x,
double  y,
Point3D p1,
Point3D p2,
Point3D p3,
Point3D result 
)

Calculates the barycentric coordinates of a point (x,y) with respect to p1, p2, p3 and stores the three barycentric coordinates in 'result'.

Thus the u-coordinate is stored in result::x, the v-coordinate in result::y and the w-coordinate in result::z. Attention: p1, p2 and p3 have to be ordered counterclockwise

double MathUtils::calcBernsteinPoly ( int  n,
int  i,
double  t 
)

calculates the value of a Bernstein polynomial

double MathUtils::calcCubicHermitePoly ( int  n,
int  i,
double  t 
)

calculates the value of a cubic Hermite polynomial

double MathUtils::cFDerBernsteinPoly ( int  n,
int  i,
double  t 
)

calculates the first derivative of a Bernstein polynomial with respect to the parameter t

double MathUtils::cFDerCubicHermitePoly ( int  n,
int  i,
double  t 
)

calculates the first derivative of a cubic Hermite polynomial with respect to the parameter t

bool MathUtils::circumcenter ( Point3D p1,
Point3D p2,
Point3D p3,
Point3D result 
)

Calculates the center of the circle passing through p1, p2 and p3.

Returns true in case of success and false otherwise (e.g. all three points on a line)

double MathUtils::crossVec ( Point3D first,
Vector3D vec1,
Point3D second,
Vector3D vec2 
)

Calculates the intersection of the two vectors vec1 and vec2, which start at first(vec1) and second(vec2) end.

The return value is t2(multiplication of v2 with t2 and adding to 'second' results the intersection point)

bool MathUtils::derVec ( const Vector3D v1,
const Vector3D v2,
Vector3D result,
double  x,
double  y 
)

Calculates the z-component of a vector with coordinates 'x' and 'y'which is in the same tangent plane as the tangent vectors 'v1' and 'v2'.

The result is assigned to 'result'

double MathUtils::distPointFromLine ( Point3D thepoint,
Point3D p1,
Point3D p2 
)

Calculates the (2 dimensional) distance from 'thepoint' to the line defined by p1 and p2.

int MathUtils::faculty ( int  n  ) 

faculty function

bool MathUtils::inCircle ( Point3D testp,
Point3D p1,
Point3D p2,
Point3D p3 
)

Tests, wheter 'testp' is inside the circle through 'p1', 'p2' and 'p3'.

bool MathUtils::inDiametral ( Point3D p1,
Point3D p2,
Point3D point 
)

Tests, whether 'point' is inside the diametral circle through 'p1' and 'p2'.

double MathUtils::leftOf ( Point3D thepoint,
Point3D p1,
Point3D p2 
)

Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.

Negativ values mean left and positiv values right. There may be numerical instabilities, so a treshold may be useful

bool MathUtils::lineIntersection ( Point3D p1,
Point3D p2,
Point3D p3,
Point3D p4,
Point3D intersection_point 
)

Returns true, if line1 (p1 to p2) and line2 (p3 to p4) intersect.

If the lines have an endpoint in common, false is returned. The intersecting point is stored in 'intersection_point.

bool MathUtils::lineIntersection ( Point3D p1,
Point3D p2,
Point3D p3,
Point3D p4 
)

Returns true, if line1 (p1 to p2) and line2 (p3 to p4) intersect.

If the lines have an endpoint in common, false is returned

int MathUtils::lower ( int  n,
int  i 
)

lower function

Referenced by QgsGraduatedSymbolDialog::adjustClassification().

double MathUtils::max ( double  x,
double  y 
)

returns the maximum of two doubles or the first argument if both are equal

Referenced by QgsGPXProvider::addFeature(), QgsVectorLayerProperties::apply(), QgsGeometry::boundingBox(), QgsVectorLayer::boundingBoxFromPointList(), QgsMapToolMoveFeature::canvasPressEvent(), QgsGeometry::closestSegmentWithContext(), QgsGeometry::closestVertex(), QgsGeometry::closestVertexWithContext(), QgsComposerLegend::drawLayerChildItems(), QgsContrastEnhancement::getMaximumPossibleValue(), QgsContrastEnhancement::getMinimumPossibleValue(), GPSData::GPSData(), GPSPoint::GPSPoint(), QgsGrassModelItem::info(), QgsGPXProvider::nextFeature(), QgsComposerLegend::paintAndDetermineSize(), QgsColorTable::print(), QgsAttributeDialog::QgsAttributeDialog(), QgsRasterBandStats::QgsRasterBandStats(), QgsVectorLayer::readXml(), QgsRect::setMinimal(), QgsGeometry::sqrDistToVertexAt(), GPSExtended::writeXML(), and GPSPoint::writeXML().

double MathUtils::min ( double  x,
double  y 
)

returns the minimum of two doubles or the first argument if both are equal

Referenced by QgsVectorLayerProperties::apply(), QgsContrastEnhancement::getMinimumPossibleValue(), QgsGrassModelItem::info(), QgsIDWInterpolator::interpolatePoint(), QgsComposerItem::mouseReleaseEvent(), QgsColorTable::print(), QgsAttributeDialog::QgsAttributeDialog(), QgsRasterBandStats::QgsRasterBandStats(), QgsVectorLayer::readXml(), and QgsRect::toString().

void MathUtils::normalFromPoints ( Point3D p1,
Point3D p2,
Point3D p3,
Vector3D vec 
)

Calculates the normal vector of the plane through the points p1, p2 and p3 and assigns the result to vec.

If the points are ordered counterclockwise, the normal will have a positive z-coordinate;

bool MathUtils::normalLeft ( Vector3D v1,
Vector3D result,
double  length 
)

Assigns the vector 'result', which is normal to the vector 'v1', on the left side of v1 and has length 'length'.

This method works only with two dimensions.

bool MathUtils::normalMinDistance ( Vector3D tangent,
Vector3D target,
Vector3D result 
)

Calculates a Vector orthogonal to 'tangent' with length 1 and closest possible to result.

Returns true in case of success and false otherwise

bool MathUtils::normalRight ( Vector3D v1,
Vector3D result,
double  length 
)

Assigns the vector 'result', which is normal to the vector 'v1', on the right side of v1 and has length 'length'.

The calculation is only in two dimensions

double MathUtils::planeTest ( Point3D test,
Point3D pt1,
Point3D pt2,
Point3D pt3 
)

Tests, if 'test' is in the same plane as 'p1', 'p2' and 'p3' and returns the z-difference from the plane to 'test.

bool MathUtils::pointInsideTriangle ( double  x,
double  y,
Point3D p1,
Point3D p2,
Point3D p3 
)

Returns true, if the point with coordinates x and y is inside (or at the edge) of the triangle p1,p2,p3 and false, if it is outside.

p1, p2 and p3 have to be ordered counterclockwise

double MathUtils::power ( double  a,
int  b 
)

power function for integer coefficients

double MathUtils::triArea ( Point3D pa,
Point3D pb,
Point3D pc 
)

returns the area of a triangle.

If the points are ordered counterclockwise, the value will be positiv. If they are ordered clockwise, the value will be negativ


Generated on Tue Oct 28 16:52:08 2008 for Quantum GIS API Documentation by  doxygen 1.5.1