Skip to content

Commit

Permalink
Fix incorrect vertexAngle calculation for circular strings
Browse files Browse the repository at this point in the history
Angle was always perpendicular to the tangent, instead of
tangential to the curve
  • Loading branch information
nyalldawson committed Sep 19, 2017
1 parent 0fba03f commit bb3170f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/geometry/qgsgeometryutils.cpp
Expand Up @@ -617,14 +617,18 @@ double QgsGeometryUtils::circleTangentDirection( const QgsPoint &tangentPoint, c
double p1Angle = QgsGeometryUtils::ccwAngle( cp1.y() - mY, cp1.x() - mX );
double p2Angle = QgsGeometryUtils::ccwAngle( cp2.y() - mY, cp2.x() - mX );
double p3Angle = QgsGeometryUtils::ccwAngle( cp3.y() - mY, cp3.x() - mX );
double angle = 0;
if ( circleClockwise( p1Angle, p2Angle, p3Angle ) )
{
return lineAngle( tangentPoint.x(), tangentPoint.y(), mX, mY );
angle = lineAngle( tangentPoint.x(), tangentPoint.y(), mX, mY ) - M_PI_2;
}
else
{
return lineAngle( mX, mY, tangentPoint.x(), tangentPoint.y() );
angle = lineAngle( mX, mY, tangentPoint.x(), tangentPoint.y() ) - M_PI_2;
}
if ( angle < 0 )
angle += 2 * M_PI;
return angle;
}

void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, QgsPointSequence &points, double tolerance, QgsAbstractGeometry::SegmentationToleranceType toleranceType, bool hasZ, bool hasM )
Expand Down

0 comments on commit bb3170f

Please sign in to comment.