[Orxonox-commit 729] r3259 - branches/netp6/src/util

scheusso at orxonox.net scheusso at orxonox.net
Tue Jun 30 16:34:48 CEST 2009


Author: scheusso
Date: 2009-06-30 16:34:48 +0200 (Tue, 30 Jun 2009)
New Revision: 3259

Modified:
   branches/netp6/src/util/Math.cc
Log:
bonus to ticket 329 ;)


Modified: branches/netp6/src/util/Math.cc
===================================================================
--- branches/netp6/src/util/Math.cc	2009-06-30 14:24:36 UTC (rev 3258)
+++ branches/netp6/src/util/Math.cc	2009-06-30 14:34:48 UTC (rev 3259)
@@ -135,10 +135,10 @@
             else
                 return orxonox::Vector2(0, 1);
         }
-      
+        
         float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
         float sin_value = sqrt( 1 - cos_value*cos_value );
-      
+        
         if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
             return orxonox::Vector2( sin_value, cos_value );
         else
@@ -175,16 +175,19 @@
             else
                 return orxonox::Vector2(0, 1);
         }
-        float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
+        //float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
+        
+        float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
+        float sin_value = sqrt( 1 - cos_value*cos_value );
 
         float distancelength = distance.length();
         if (distancelength == 0) return orxonox::Vector2(0, 0);
         float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI;
 
         if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
-            return orxonox::Vector2(sin(angle) * radius, cos(angle) * radius);
+            return orxonox::Vector2( sin_value * radius, cos_value * radius);
         else
-            return orxonox::Vector2(-sin(angle) * radius, cos(angle) * radius);
+            return orxonox::Vector2( -sin_value * radius, cos_value * radius);
     }
 
     /**




More information about the Orxonox-commit mailing list