16 #ifndef QGSGEOMETRYUTILS_H
17 #define QGSGEOMETRYUTILS_H
21 #include "qgis_core.h"
93 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;
157 static bool lineCircleIntersection(
const QgsPointXY ¢er,
double radius,
171 static int circleCircleIntersections(
QgsPointXY center1,
double radius1,
183 static bool tangentPointAndCircle(
const QgsPointXY ¢er,
double radius,
203 static int circleCircleOuterTangents(
226 static int circleCircleInnerTangents(
240 double nx = s2.y() - s1.y();
241 double ny = -( s2.x() - s1.x() );
242 double t = ( p.
x() * ny - p.
y() * nx - s1.x() * ny + s1.y() * nx ) / ( ( s2.x() - s1.x() ) * ny - ( s2.y() - s1.y() ) * nx );
243 return t < 0. ? s1 : t > 1. ? s2 :
QgsPoint( s1.x() + ( s2.x() - s1.x() ) * t, s1.y() + ( s2.y() - s1.y() ) * t );
264 static QVector<SelfIntersection> selfIntersections(
const QgsAbstractGeometry *geom,
int part,
int ring,
double tolerance )
SIP_SKIP;
273 static int leftOfLine(
const double x,
const double y,
const double x1,
const double y1,
const double x2,
const double y2 )
SIP_HOLDGIL;
300 static void pointOnLineWithDistance(
double x1,
double y1,
double x2,
double y2,
double distance,
double &x,
double &y,
301 double *z1 =
nullptr,
double *z2 =
nullptr,
double *z =
nullptr,
302 double *m1 =
nullptr,
double *m2 =
nullptr,
double *m =
nullptr )
SIP_SKIP;
315 static
double ccwAngle(
double dy,
double dx )
SIP_HOLDGIL;
327 static
bool circleClockwise(
double angle1,
double angle2,
double angle3 )
SIP_HOLDGIL;
330 static
bool circleAngleBetween(
double angle,
double angle1,
double angle2,
bool clockwise )
SIP_HOLDGIL;
336 static
bool angleOnCircle(
double angle,
double angle1,
double angle2,
double angle3 )
SIP_HOLDGIL;
339 static
double circleLength(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
342 static
double sweepAngle(
double centerX,
double centerY,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
375 bool hasZ = false,
bool hasM = false );
406 static
double interpolateArcValue(
double angle,
double a1,
double a2,
double a3,
double zm1,
double zm2,
double zm3 )
SIP_HOLDGIL;
465 static
double lineAngle(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL;
478 static
double angleBetweenThreePoints(
double x1,
double y1,
double x2,
double y2,
490 static
double linePerpendicularAngle(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL;
496 static
double averageAngle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
504 static
double averageAngle(
double a1,
double a2 )
SIP_HOLDGIL;
519 static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() )
SIP_SKIP;
559 static
QgsPointXY interpolatePointOnLine(
double x1,
double y1,
double x2,
double y2,
double fraction )
SIP_HOLDGIL;
591 static
QgsPointXY interpolatePointOnLineByValue(
double x1,
double y1,
double v1,
double x2,
double y2,
double v2,
double value )
SIP_HOLDGIL;
696 static
double triangleArea(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY )
SIP_HOLDGIL;
715 static
void weightedPointInTriangle(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY,
741 double minDist = std::numeric_limits<double>::max();
742 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
744 int minDistLeftOf = 0;
745 double sqrDist = 0.0;
746 int vertexOffset = 0;
750 for (
int i = 0; i < container.size(); ++i )
752 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter,
leftOf, epsilon );
753 if ( sqrDist >= 0 && sqrDist < minDist )
756 minDistSegmentX = segmentPt.x();
757 minDistSegmentY = segmentPt.y();
758 minDistVertexAfter = vertexAfter;
759 minDistVertexAfter.
vertex = vertexAfter.vertex + vertexOffset;
760 minDistVertexAfter.
part = vertexAfter.part + partOffset;
761 minDistVertexAfter.
ring = vertexAfter.ring + ringOffset;
768 if ( ctype == Vertex )
771 vertexOffset += container.at( i )->nCoordinates() - 1;
773 else if ( ctype == Ring )
777 else if ( ctype == Part )
783 if ( minDist == std::numeric_limits<double>::max() )
786 segmentPt.setX( minDistSegmentX );
787 segmentPt.setY( minDistSegmentY );
788 vertexAfter = minDistVertexAfter;
797 #endif // QGSGEOMETRYUTILS_H