16 #ifndef QGSGEOMETRYUTILS_H
17 #define QGSGEOMETRYUTILS_H
21 #include "qgis_core.h"
94 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;
104 static double distToInfiniteLine(
const QgsPoint &point,
const QgsPoint &linePoint1,
const QgsPoint &linePoint2,
double epsilon = 1e-7 );
168 static bool lineCircleIntersection(
const QgsPointXY ¢er,
double radius,
182 static int circleCircleIntersections(
const QgsPointXY ¢er1,
double radius1,
194 static bool tangentPointAndCircle(
const QgsPointXY ¢er,
double radius,
214 static int circleCircleOuterTangents(
237 static int circleCircleInnerTangents(
251 const double nx = s2.y() - s1.y();
252 const double ny = -( s2.x() - s1.x() );
253 const double t = ( p.
x() * ny - p.
y() * nx - s1.x() * ny + s1.y() * nx ) / ( ( s2.x() - s1.x() ) * ny - ( s2.y() - s1.y() ) * nx );
254 return t < 0. ? s1 : t > 1. ? s2 :
QgsPoint( s1.x() + ( s2.x() - s1.x() ) * t, s1.y() + ( s2.y() - s1.y() ) * t );
275 static QVector<SelfIntersection> selfIntersections(
const QgsAbstractGeometry *geom,
int part,
int ring,
double tolerance )
SIP_SKIP;
284 static int leftOfLine(
const double x,
const double y,
const double x1,
const double y1,
const double x2,
const double y2 )
SIP_HOLDGIL;
311 static void pointOnLineWithDistance(
double x1,
double y1,
double x2,
double y2,
double distance,
double &x,
double &y,
312 double *z1 =
nullptr,
double *z2 =
nullptr,
double *z =
nullptr,
313 double *m1 =
nullptr,
double *m2 =
nullptr,
double *m =
nullptr )
SIP_SKIP;
342 static
void perpendicularOffsetPointAlongSegment(
double x1,
double y1,
double x2,
double y2,
double proportion,
double offset,
double *x
SIP_OUT,
double *y
SIP_OUT );
355 static
double ccwAngle(
double dy,
double dx )
SIP_HOLDGIL;
367 static
bool circleClockwise(
double angle1,
double angle2,
double angle3 )
SIP_HOLDGIL;
370 static
bool circleAngleBetween(
double angle,
double angle1,
double angle2,
bool clockwise )
SIP_HOLDGIL;
376 static
bool angleOnCircle(
double angle,
double angle1,
double angle2,
double angle3 )
SIP_HOLDGIL;
379 static
double circleLength(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
382 static
double sweepAngle(
double centerX,
double centerY,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
415 bool hasZ = false,
bool hasM = false );
446 static
double interpolateArcValue(
double angle,
double a1,
double a2,
double a3,
double zm1,
double zm2,
double zm3 )
SIP_HOLDGIL;
505 static
double lineAngle(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL;
518 static
double angleBetweenThreePoints(
double x1,
double y1,
double x2,
double y2,
530 static
double linePerpendicularAngle(
double x1,
double y1,
double x2,
double y2 )
SIP_HOLDGIL;
536 static
double averageAngle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )
SIP_HOLDGIL;
544 static
double averageAngle(
double a1,
double a2 )
SIP_HOLDGIL;
559 static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() )
SIP_SKIP;
583 static
int closestSideOfRectangle(
double right,
double bottom,
double left,
double top,
double x,
double y );
623 static
QgsPointXY interpolatePointOnLine(
double x1,
double y1,
double x2,
double y2,
double fraction )
SIP_HOLDGIL;
655 static
QgsPointXY interpolatePointOnLineByValue(
double x1,
double y1,
double v1,
double x2,
double y2,
double v2,
double value )
SIP_HOLDGIL;
710 static
void perpendicularCenterSegment(
double centerPointX,
double centerPointY,
711 double segmentPoint1x,
double segmentPoint1y,
712 double segmentPoint2x,
double segmentPoint2y,
713 double &perpendicularSegmentPoint1x
SIP_OUT,
double &perpendicularSegmentPoint1y
SIP_OUT,
714 double &perpendicularSegmentPoint2x
SIP_OUT,
double &perpendicularSegmentPoint2y
SIP_OUT,
715 double segmentLength = 0
790 static
double triangleArea(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY )
SIP_HOLDGIL;
809 static
void weightedPointInTriangle(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY,
830 return transferFirstZValueToPoint( points, point );
890 for (
auto it = verticesBegin ; it != verticesEnd ; ++it )
892 if ( !mFound && ( *it ).isMeasure() )
895 point.
setM( ( *it ).m() );
898 if ( !zFound && ( *it ).is3D() )
901 point.
setZ( ( *it ).z() );
904 if ( zFound && mFound )
908 return zFound || mFound;
974 static bool angleBisector(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY,
double dX,
double dY,
993 static bool bisector(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY,
1007 double minDist = std::numeric_limits<double>::max();
1008 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
1010 int minDistLeftOf = 0;
1011 double sqrDist = 0.0;
1012 int vertexOffset = 0;
1016 for (
int i = 0; i < container.size(); ++i )
1018 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter,
leftOf, epsilon );
1019 if ( sqrDist >= 0 && sqrDist < minDist )
1022 minDistSegmentX = segmentPt.x();
1023 minDistSegmentY = segmentPt.y();
1024 minDistVertexAfter = vertexAfter;
1025 minDistVertexAfter.
vertex = vertexAfter.vertex + vertexOffset;
1026 minDistVertexAfter.
part = vertexAfter.part + partOffset;
1027 minDistVertexAfter.
ring = vertexAfter.ring + ringOffset;
1034 if ( ctype == Vertex )
1037 vertexOffset += container.at( i )->nCoordinates() - 1;
1039 else if ( ctype == Ring )
1043 else if ( ctype == Part )
1049 if ( minDist == std::numeric_limits<double>::max() )
1052 segmentPt.setX( minDistSegmentX );
1053 segmentPt.setY( minDistSegmentY );
1054 vertexAfter = minDistVertexAfter;
1063 #endif // QGSGEOMETRYUTILS_H