40 static double sqrDistance3D(
double x1,
double y1,
double z1,
double x2,
double y2,
double z2 )
SIP_HOLDGIL {
return ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) + ( z1 - z2 ) * ( z1 - z2 ); }
48 static double distance3D(
double x1,
double y1,
double z1,
double x2,
double y2,
double z2 )
SIP_HOLDGIL {
return std::sqrt( sqrDistance3D( x1, y1, z1, x2, y2, z2 ) ); }
53 static double sqrDistance2D(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL {
return ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ); }
58 static double distance2D(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL {
return std::sqrt( sqrDistance2D( x1, y1, x2, y2 ) ); }
63 static double sqrDistToLine(
double ptX,
double ptY,
double x1,
double y1,
double x2,
double y2,
double &minDistX
SIP_OUT,
double &minDistY
SIP_OUT,
double epsilon )
SIP_HOLDGIL;
72 static int leftOfLine(
const double x,
const double y,
const double x1,
const double y1,
const double x2,
const double y2 )
SIP_HOLDGIL;
83 static void pointOnLineWithDistance(
double x1,
double y1,
double x2,
double y2,
double distance,
double &x,
double &y,
84 double *z1 =
nullptr,
double *z2 =
nullptr,
double *z =
nullptr,
85 double *m1 =
nullptr,
double *m2 =
nullptr,
double *m =
nullptr )
SIP_SKIP;
114 static
void perpendicularOffsetPointAlongSegment(
double x1,
double y1,
double x2,
double y2,
double proportion,
double offset,
double *x
SIP_OUT,
double *y
SIP_OUT );
117 static
double ccwAngle(
double dy,
double dx )
SIP_HOLDGIL;
120 static
void circleCenterRadius(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double &radius
SIP_OUT,
129 static
bool circleClockwise(
double angle1,
double angle2,
double angle3 )
SIP_HOLDGIL;
132 static
bool circleAngleBetween(
double angle,
double angle1,
double angle2,
bool clockwise )
SIP_HOLDGIL;
138 static
bool angleOnCircle(
double angle,
double angle1,
double angle2,
double angle3 )
SIP_HOLDGIL;
141 static
double circleLength(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
144 static
double sweepAngle(
double centerX,
double centerY,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
149 static
double interpolateArcValue(
double angle,
double a1,
double a2,
double a3,
double zm1,
double zm2,
double zm3 )
SIP_HOLDGIL;
156 static
double normalizedAngle(
double angle )
SIP_HOLDGIL;
166 static
double lineAngle(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL;
179 static
double angleBetweenThreePoints(
double x1,
double y1,
double x2,
double y2,
191 static
double linePerpendicularAngle(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL;
197 static
double averageAngle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
205 static
double averageAngle(
double a1,
double a2 )
SIP_HOLDGIL;
229 static
int closestSideOfRectangle(
double right,
double bottom,
double left,
double top,
double x,
double y );
254 static
void perpendicularCenterSegment(
double centerPointX,
double centerPointY,
255 double segmentPoint1x,
double segmentPoint1y,
256 double segmentPoint2x,
double segmentPoint2y,
257 double &perpendicularSegmentPoint1x
SIP_OUT,
double &perpendicularSegmentPoint1y
SIP_OUT,
258 double &perpendicularSegmentPoint2x
SIP_OUT,
double &perpendicularSegmentPoint2y
SIP_OUT,
259 double segmentLength = 0
334 static
double triangleArea(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY )
SIP_HOLDGIL;
344 static
double pointFractionAlongLine(
double x1,
double y1,
double x2,
double y2,
double px,
double py );
363 static
void weightedPointInTriangle(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY,
372 static
bool pointsAreCollinear(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double epsilon );
395 static
bool angleBisector(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY,
double dX,
double dY,
414 static
bool bisector(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY,
452 static
bool segmentIntersection(
double p1x,
double p1y,
double p2x,
double p2y,
double q1x,
double q1y,
double q2x,
double q2y,
double &intersectionPointX
SIP_OUT,
double &intersectionPointY
SIP_OUT,
bool &isIntersection
SIP_OUT,
double tolerance = 1e-8,
bool acceptImproperIntersection = false )
SIP_HOLDGIL;
472 static
void project(
double aX,
double aY,
double aZ,
double distance,
double azimuth,
double inclination,
double &resultX
SIP_OUT,
double &resultY
SIP_OUT,
double &resultZ
SIP_OUT )
SIP_HOLDGIL;
482 static
double azimuth(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL;
505 template<
typename T,
typename... Args>
506 static bool fuzzyEqual( T epsilon,
const Args &... args )
noexcept
508 static_assert( (
sizeof...( args ) % 2 == 0 ||
sizeof...( args ) != 0 ),
"The number of arguments must be greater than 0 and even" );
509 constexpr size_t numArgs =
sizeof...( args );
511 T values[] = {
static_cast<T
>( args )...};
513 for (
size_t i = 0; i < numArgs / 2; ++i )
515 result = result &&
qgsNumberNear( values[i], values[i + numArgs / 2], epsilon );
541 template<
typename T,
typename... Args>
544 static_assert( (
sizeof...( args ) % 2 == 0 ||
sizeof...( args ) >= 4 ),
"The number of arguments must be greater than 4 and even" );
545 constexpr size_t numArgs =
sizeof...( args );
546 const T squaredEpsilon = epsilon * epsilon;
549 T values[] = {
static_cast<T
>( args )...};
551 for (
size_t i = 0; i < numArgs / 2; ++i )
553 const T diff = values[i] - values[i + numArgs / 2];
557 return sum < squaredEpsilon;
Convenience functions for geometry utils.
static double sqrDistance2D(double x1, double y1, double x2, double y2)
Returns the squared 2D distance between (x1, y1) and (x2, y2).
static double distance2D(double x1, double y1, double x2, double y2)
Returns the 2D distance between (x1, y1) and (x2, y2).
static bool fuzzyEqual(T epsilon, const Args &... args) noexcept
Performs fuzzy comparison between pairs of values within a specified epsilon.
static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the 3D distance between (x1, y1, z1) and (x2, y2, z2).
static double sqrDistance3D(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the squared 3D distance between (x1, y1, z1) and (x2, y2, z2).
static bool fuzzyDistanceEqual(T epsilon, const Args &... args) noexcept
Compare equality between multiple pairs of values with a specified epsilon.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
A class to represent a vector.
bool qgsNumberNear(T a, T b, T epsilon=std::numeric_limits< T >::epsilon() *4)
Compare two numbers of type T (but allow some difference)