Skip to content
Permalink
Browse files

Changed TOL tests

  • Loading branch information
homann committed Aug 17, 2012
1 parent 96b2d51 commit 3d380c6d6d2d157c608f4db18eae96f0e2df59b7
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/app/qgsdecorationnortharrow.cpp
@@ -255,20 +255,24 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
double x = cos( p1.y() ) * sin( p2.y() ) -
sin( p1.y() ) * cos( p2.y() ) * cos( p2.x() - p1.x() );

// Use TOL to decide if the quotient is big enough.
// Both x and y can be very small, if heavily zoomed
// For small y/x, we set directly angle 0. Not sure
// if this is needed.
if ( y > 0.0 )
{
if ( x > TOL )
if ( x > 0.0 && ( y / x ) > TOL )
angle = atan( y / x );
else if ( x < -TOL )
else if ( x < 0.0 && ( y / x ) < -TOL )
angle = PI - atan( -y / x );
else
angle = 0.5 * PI;
}
else if ( y < 0.0 )
{
if ( x > TOL )
if ( x > 0.0 && ( y / x ) < -TOL )
angle = -atan( -y / x );
else if ( x < -TOL )
else if ( x < 0.0 && ( y / x ) > TOL )
angle = atan( y / x ) - PI;
else
angle = 1.5 * PI;

0 comments on commit 3d380c6

Please sign in to comment.
You can’t perform that action at this time.