[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [marble] src/plugins/render/annotate: Move the polygon and have the shape always stay the same witho
From:       Torsten Rahn <rahn () kde ! org>
Date:       2014-08-10 22:24:15
Message-ID: E1XGbXD-0004GN-PD () scm ! kde ! org
[Download RAW message or body]

Git commit 262ee272666d609821fd60db827c6d8903a9f77a by Torsten Rahn.
Committed on 10/08/2014 at 22:19.
Pushed by rahn into branch 'master'.

Move the polygon and have the shape always stay the same without getting
distorted.

M  +19   -19   src/plugins/render/annotate/AreaAnnotation.cpp

http://commits.kde.org/marble/262ee272666d609821fd60db827c6d8903a9f77a

diff --git a/src/plugins/render/annotate/AreaAnnotation.cpp \
b/src/plugins/render/annotate/AreaAnnotation.cpp index 71140df..c2bea64 100644
--- a/src/plugins/render/annotate/AreaAnnotation.cpp
+++ b/src/plugins/render/annotate/AreaAnnotation.cpp
@@ -26,7 +26,6 @@
 #include "MarbleMath.h"
 #include "MergingNodesAnimation.h"
 
-
 namespace Marble {
 
 
@@ -1003,6 +1002,9 @@ bool AreaAnnotation::processEditingOnMove( QMouseEvent \
*mouseEvent )  GeoDataCoordinates::Radian );
     const GeoDataCoordinates newCoords( lon, lat );
 
+    qreal deltaLat = lat - m_movedPointCoords.latitude();
+    qreal deltaLon = lon - m_movedPointCoords.longitude();
+
     if ( m_interactingObj == InteractingNode ) {
         GeoDataPolygon *polygon = static_cast<GeoDataPolygon*>( \
placemark()->geometry() );  GeoDataLinearRing &outerRing = polygon->outerBoundary();
@@ -1024,34 +1026,32 @@ bool AreaAnnotation::processEditingOnMove( QMouseEvent \
*mouseEvent )  GeoDataLinearRing outerRing = polygon->outerBoundary();
         QVector<GeoDataLinearRing> innerRings = polygon->innerBoundaries();
 
-        const qreal bearing = m_movedPointCoords.bearing( newCoords );
-        const qreal distance = distanceSphere( newCoords, m_movedPointCoords );
+        Quaternion latRectAxis = Quaternion::fromEuler( 0, lon, 0);
+        Quaternion latAxis = Quaternion::fromEuler( -deltaLat, 0, 0);
+        Quaternion lonAxis = Quaternion::fromEuler(0, deltaLon, 0);
+        Quaternion rotAxis = latRectAxis * latAxis * latRectAxis.inverse() * \
lonAxis; +
+
         polygon->outerBoundary().clear();
         polygon->innerBoundaries().clear();
 
-        for ( int i = 0; i < outerRing.size(); ++i ) {
-            GeoDataCoordinates movedPoint = outerRing.at(i).moveByBearing( bearing, \
                distance );
-            qreal lon = movedPoint.longitude();
-            qreal lat = movedPoint.latitude();
-
-            GeoDataCoordinates::normalizeLonLat( lon, lat );
-            movedPoint.setLongitude( lon );
-            movedPoint.setLatitude( lat );
+        qreal lonRotated, latRotated;
 
+        for ( int i = 0; i < outerRing.size(); ++i ) {
+            Quaternion qpos = outerRing.at(i).quaternion();
+            qpos.rotateAroundAxis(rotAxis);
+            qpos.getSpherical( lonRotated, latRotated );
+            GeoDataCoordinates movedPoint( lonRotated, latRotated, 0 );
             polygon->outerBoundary().append( movedPoint );
         }
 
         for ( int i = 0; i < innerRings.size(); ++i ) {
             GeoDataLinearRing newRing( Tessellate );
             for ( int j = 0; j < innerRings.at(i).size(); ++j ) {
-                GeoDataCoordinates movedPoint = \
                innerRings.at(i).at(j).moveByBearing( bearing, distance );
-                qreal lon = movedPoint.longitude();
-                qreal lat = movedPoint.latitude();
-
-                GeoDataCoordinates::normalizeLonLat( lon, lat );
-                movedPoint.setLongitude( lon );
-                movedPoint.setLatitude( lat );
-
+                Quaternion qpos = innerRings.at(i).at(j).quaternion();
+                qpos.rotateAroundAxis(rotAxis);
+                qpos.getSpherical( lonRotated, latRotated );
+                GeoDataCoordinates movedPoint( lonRotated, latRotated, 0 );
                 newRing.append( movedPoint );
             }
             polygon->innerBoundaries().append( newRing );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic