Skip to content

Commit 3d380c6

Browse files
committedAug 17, 2012
Changed TOL tests
1 parent 96b2d51 commit 3d380c6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎src/app/qgsdecorationnortharrow.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,24 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
255255
double x = cos( p1.y() ) * sin( p2.y() ) -
256256
sin( p1.y() ) * cos( p2.y() ) * cos( p2.x() - p1.x() );
257257

258+
// Use TOL to decide if the quotient is big enough.
259+
// Both x and y can be very small, if heavily zoomed
260+
// For small y/x, we set directly angle 0. Not sure
261+
// if this is needed.
258262
if ( y > 0.0 )
259263
{
260-
if ( x > TOL )
264+
if ( x > 0.0 && ( y / x ) > TOL )
261265
angle = atan( y / x );
262-
else if ( x < -TOL )
266+
else if ( x < 0.0 && ( y / x ) < -TOL )
263267
angle = PI - atan( -y / x );
264268
else
265269
angle = 0.5 * PI;
266270
}
267271
else if ( y < 0.0 )
268272
{
269-
if ( x > TOL )
273+
if ( x > 0.0 && ( y / x ) < -TOL )
270274
angle = -atan( -y / x );
271-
else if ( x < -TOL )
275+
else if ( x < 0.0 && ( y / x ) > TOL )
272276
angle = atan( y / x ) - PI;
273277
else
274278
angle = 1.5 * PI;

0 commit comments

Comments
 (0)
Please sign in to comment.