QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
Functions
MathUtils Namespace Reference

Functions

double ANALYSIS_EXPORT angle (QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
 Calculates the angle between two segments (in 2 dimension, z-values are ignored)
 
bool ANALYSIS_EXPORT BarycentricToXY (double u, double v, double w, QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *result)
 
bool ANALYSIS_EXPORT calcBarycentricCoordinates (double x, double y, QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *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 ANALYSIS_EXPORT calcBernsteinPoly (int n, int i, double t)
 Calculates the value of a Bernstein polynomial.
 
double ANALYSIS_EXPORT calcCubicHermitePoly (int n, int i, double t)
 Calculates the value of a cubic Hermite polynomial.
 
double ANALYSIS_EXPORT cFDerBernsteinPoly (int n, int i, double t)
 Calculates the first derivative of a Bernstein polynomial with respect to the parameter t.
 
double ANALYSIS_EXPORT cFDerCubicHermitePoly (int n, int i, double t)
 Calculates the first derivative of a cubic Hermite polynomial with respect to the parameter t.
 
bool ANALYSIS_EXPORT circumcenter (QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *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 ANALYSIS_EXPORT crossVec (QgsPoint *first, Vector3D *vec1, QgsPoint *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 ANALYSIS_EXPORT 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 ANALYSIS_EXPORT distPointFromLine (QgsPoint *thepoint, QgsPoint *p1, QgsPoint *p2)
 Calculates the (2 dimensional) distance from 'thepoint' to the line defined by p1 and p2.
 
int ANALYSIS_EXPORT faculty (int n)
 Faculty function.
 
bool ANALYSIS_EXPORT inCircle (QgsPoint *testp, QgsPoint *p1, QgsPoint *p2, QgsPoint *p3)
 Tests, whether 'testp' is inside the circle through 'p1', 'p2' and 'p3'.
 
bool ANALYSIS_EXPORT inDiametral (QgsPoint *p1, QgsPoint *p2, QgsPoint *point)
 Tests, whether 'point' is inside the diametral circle through 'p1' and 'p2'.
 
double ANALYSIS_EXPORT leftOf (const QgsPoint &thepoint, const QgsPoint *p1, const QgsPoint *p2)
 Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. Negative values mean left and positive values right. There may be numerical instabilities, so a threshold may be useful.
 
bool ANALYSIS_EXPORT lineIntersection (QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *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.
 
bool ANALYSIS_EXPORT lineIntersection (QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4, QgsPoint *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.
 
int ANALYSIS_EXPORT lower (int n, int i)
 Lower function.
 
void ANALYSIS_EXPORT normalFromPoints (QgsPoint *p1, QgsPoint *p2, QgsPoint *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 ANALYSIS_EXPORT 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 ANALYSIS_EXPORT 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 ANALYSIS_EXPORT 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 ANALYSIS_EXPORT planeTest (QgsPoint *test, QgsPoint *pt1, QgsPoint *pt2, QgsPoint *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 ANALYSIS_EXPORT pointInsideTriangle (double x, double y, QgsPoint *p1, QgsPoint *p2, QgsPoint *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 ANALYSIS_EXPORT triArea (QgsPoint *pa, QgsPoint *pb, QgsPoint *pc)
 Returns the area of a triangle. If the points are ordered counterclockwise, the value will be positive. If they are ordered clockwise, the value will be negative.
 

Function Documentation

◆ angle()

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

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

Definition at line 712 of file MathUtils.cpp.

◆ BarycentricToXY()

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

Definition at line 51 of file MathUtils.cpp.

◆ calcBarycentricCoordinates()

bool MathUtils::calcBarycentricCoordinates ( double  x,
double  y,
QgsPoint p1,
QgsPoint p2,
QgsPoint p3,
QgsPoint 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.

Definition at line 23 of file MathUtils.cpp.

◆ calcBernsteinPoly()

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

Calculates the value of a Bernstein polynomial.

Definition at line 102 of file MathUtils.cpp.

◆ calcCubicHermitePoly()

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

Calculates the value of a cubic Hermite polynomial.

Definition at line 363 of file MathUtils.cpp.

◆ cFDerBernsteinPoly()

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

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

Definition at line 112 of file MathUtils.cpp.

◆ cFDerCubicHermitePoly()

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

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

Definition at line 396 of file MathUtils.cpp.

◆ circumcenter()

bool MathUtils::circumcenter ( QgsPoint p1,
QgsPoint p2,
QgsPoint p3,
QgsPoint 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)

Definition at line 117 of file MathUtils.cpp.

◆ crossVec()

double MathUtils::crossVec ( QgsPoint first,
Vector3D vec1,
QgsPoint 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)

Definition at line 577 of file MathUtils.cpp.

◆ derVec()

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'.

Definition at line 435 of file MathUtils.cpp.

◆ distPointFromLine()

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

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

Definition at line 152 of file MathUtils.cpp.

◆ faculty()

int MathUtils::faculty ( int  n)

Faculty function.

Definition at line 172 of file MathUtils.cpp.

◆ inCircle()

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

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

Definition at line 177 of file MathUtils.cpp.

◆ inDiametral()

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

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

Definition at line 217 of file MathUtils.cpp.

◆ leftOf()

double MathUtils::leftOf ( const QgsPoint thepoint,
const QgsPoint p1,
const QgsPoint p2 
)

Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. Negative values mean left and positive values right. There may be numerical instabilities, so a threshold may be useful.

Definition at line 222 of file MathUtils.cpp.

◆ lineIntersection() [1/2]

bool MathUtils::lineIntersection ( QgsPoint p1,
QgsPoint p2,
QgsPoint p3,
QgsPoint 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.

Definition at line 241 of file MathUtils.cpp.

◆ lineIntersection() [2/2]

bool MathUtils::lineIntersection ( QgsPoint p1,
QgsPoint p2,
QgsPoint p3,
QgsPoint p4,
QgsPoint 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.

Definition at line 284 of file MathUtils.cpp.

◆ lower()

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

Lower function.

Definition at line 337 of file MathUtils.cpp.

◆ normalFromPoints()

void MathUtils::normalFromPoints ( QgsPoint p1,
QgsPoint p2,
QgsPoint 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;.

Definition at line 560 of file MathUtils.cpp.

◆ normalLeft()

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.

Definition at line 450 of file MathUtils.cpp.

◆ normalMinDistance()

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.

Definition at line 624 of file MathUtils.cpp.

◆ normalRight()

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.

Definition at line 505 of file MathUtils.cpp.

◆ planeTest()

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

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

Definition at line 695 of file MathUtils.cpp.

◆ pointInsideTriangle()

bool MathUtils::pointInsideTriangle ( double  x,
double  y,
QgsPoint p1,
QgsPoint p2,
QgsPoint 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.

Definition at line 606 of file MathUtils.cpp.

◆ triArea()

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

Returns the area of a triangle. If the points are ordered counterclockwise, the value will be positive. If they are ordered clockwise, the value will be negative.

Definition at line 349 of file MathUtils.cpp.