From 895c4a40717247279f339e51bc2e41cb9b8b329c Mon Sep 17 00:00:00 2001 From: jef Date: Tue, 25 Jan 2011 08:23:52 +0000 Subject: [PATCH] fix #3434 git-svn-id: http://svn.osgeo.org/qgis/trunk@15076 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/core/symbology-ng/qgslinesymbollayerv2.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/core/symbology-ng/qgslinesymbollayerv2.cpp b/src/core/symbology-ng/qgslinesymbollayerv2.cpp index 56e5a43ace0..3336d38f2c4 100644 --- a/src/core/symbology-ng/qgslinesymbollayerv2.cpp +++ b/src/core/symbology-ng/qgslinesymbollayerv2.cpp @@ -622,19 +622,6 @@ void QgsLineDecorationSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& conte { } -static double _calculateAngle( double x1, double y1, double x2, double y2 ) -{ - // return angle (in radians) between two points - if ( x1 == x2 ) - return M_PI *( y2 >= y1 ? 1 / 2 : 3 / 2 ); // angle is 90 or 270 - - double t = ( y2 - y1 ) / ( x2 - x1 ); - if ( t >= 0 ) - return atan( t ) + ( y2 >= y1 ? 0 : M_PI ); - else // t < 0 - return atan( t ) + ( y2 >= y1 ? M_PI : 0 ); // atan is positive / negative -} - void QgsLineDecorationSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) { // draw arrow at the end of line @@ -648,8 +635,8 @@ void QgsLineDecorationSymbolLayerV2::renderPolyline( const QPolygonF& points, Qg int cnt = points.count(); QPointF p1 = points.at( cnt - 2 ); QPointF p2 = points.at( cnt - 1 ); - double angle = _calculateAngle( p1.x(), p1.y(), p2.x(), p2.y() ); + double angle = atan2( p2.y() - p1.y(), p2.x() - p1.x() ); double size = context.outputLineWidth( mWidth * 8 ); double angle1 = angle + M_PI / 6; double angle2 = angle - M_PI / 6;