16 #ifndef QGSGEOMETRYUTILS_H
17 #define QGSGEOMETRYUTILS_H
46 static double sqrDistToLine(
double ptX,
double ptY,
double x1,
double y1,
double x2,
double y2,
double& minDistX,
double& minDistY,
double epsilon );
49 static double leftOfLine(
double x,
double y,
double x1,
double y1,
double x2,
double y2 );
56 static double ccwAngle(
double dy,
double dx );
60 double& centerX,
double& centerY );
63 static bool circleClockwise(
double angle1,
double angle2,
double angle3 );
66 static bool circleAngleBetween(
double angle,
double angle1,
double angle2,
bool clockwise );
71 static bool angleOnCircle(
double angle,
double angle1,
double angle2,
double angle3 );
74 static double circleLength(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
77 static double sweepAngle(
double centerX,
double centerY,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
117 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
119 bool minDistLeftOf =
false;
120 double sqrDist = 0.0;
121 int vertexOffset = 0;
125 for (
int i = 0; i < container.size(); ++i )
127 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter, leftOf, epsilon );
128 if ( sqrDist < minDist )
131 minDistSegmentX = segmentPt.
x();
132 minDistSegmentY = segmentPt.
y();
133 minDistVertexAfter = vertexAfter;
134 minDistVertexAfter.
vertex = vertexAfter.
vertex + vertexOffset;
135 minDistVertexAfter.
part = vertexAfter.
part + partOffset;
136 minDistVertexAfter.
ring = vertexAfter.
ring + ringOffset;
143 if ( ctype == VERTEX )
146 vertexOffset += container.at( i )->nCoordinates() - 1;
148 else if ( ctype == RING )
152 else if ( ctype == PART )
158 segmentPt.
setX( minDistSegmentX );
159 segmentPt.
setY( minDistSegmentY );
160 vertexAfter = minDistVertexAfter;
163 *leftOf = minDistLeftOf;
169 #endif // QGSGEOMETRYUTILS_H
Abstract base class for all geometries.
static double closestSegmentFromComponents(T &container, componentType ctype, const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon)
Contains various geometry utility functions.
Utility class for identifying a unique vertex within a geometry.
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.