From d6ca8f050f45bb8984b4aba3e68eac6edb805eed Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 24 Jan 2011 20:37:32 +0100 Subject: [PATCH] Fix math used to compute angles of horizontal and vertical lines (#3434). --- src/core/symbology-ng/qgslinesymbollayerv2.cpp | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/core/symbology-ng/qgslinesymbollayerv2.cpp b/src/core/symbology-ng/qgslinesymbollayerv2.cpp index 56e5a43..1a340ab 100644 --- a/src/core/symbology-ng/qgslinesymbollayerv2.cpp +++ b/src/core/symbology-ng/qgslinesymbollayerv2.cpp @@ -626,7 +626,10 @@ 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 + return M_PI * ( y2 >= y1 ? 1.0 / 2 : 3.0 / 2 ); // angle is 90 or 270 + + if ( y1 == y2 ) + return M_PI * ( x2 >= x1 ? 0 : 1 ); // angle is 0 or 180 double t = ( y2 - y1 ) / ( x2 - x1 ); if ( t >= 0 ) -- 1.7.0.4