[Marble-commits] KDE/kdeedu/marble/src/lib/Projections

Bernhard Beschow bbeschow at cs.tu-berlin.de
Wed Sep 1 13:34:37 CEST 2010


SVN commit 1170546 by beschow:

simplify SphericalProjection::geoCoordinates(), part 3

We will simplify the definition of qz and eliminate qr and qr2z:

1) Simplify qr2z:
qr2z is defined as: qr2z = qr - qx * qx.
Replacing qr by its definition yields: qr2z = (1.0 - qy * qy) - qx * qx

2) Simplify qz:
Since 1 > qx * qx + qy * qy is ensured by the if-statement, qr2z > 0.0 is always true. Hence, qz = sqrt( qrz ).
Replacing qrz by its definition yields: qz = sqrt( 1 - qx * qx - qy * qy )

3) Eliminate qr and qr2z since they are not needed any more.

 M  +1 -4      SphericalProjection.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/Projections/SphericalProjection.cpp #1170545:1170546
@@ -201,11 +201,8 @@
     const qreal qy = -(qreal)( y - viewport->height() / 2 ) * inverseRadius;
 
     if ( 1 > qx * qx + qy * qy ) {
-        qreal qr = 1.0 - qy * qy;
+        const qreal qz = sqrt( 1 - qx * qx - qy * qy );
 
-        qreal qr2z = qr - qx * qx;
-        qreal qz   = ( qr2z > 0.0 ) ? sqrt( qr2z ) : 0.0;
-
         Quaternion  qpos( 0.0, qx, qy, qz );
         qpos.rotateAroundAxis( viewport->planetAxis() );
         qpos.getSpherical( lon, lat );


More information about the Marble-commits mailing list