]> git.mxchange.org Git - flightgear.git/commitdiff
Remove all (2) uses of simgear/math/vector.h from FlightGear.
authorJames Turner <zakalawe@mac.com>
Fri, 23 Jul 2010 12:26:07 +0000 (13:26 +0100)
committerJames Turner <zakalawe@mac.com>
Fri, 23 Jul 2010 12:26:07 +0000 (13:26 +0100)
src/Instrumentation/HUD/HUD_ladder.cxx
src/Instrumentation/navradio.cxx
src/Main/viewer.cxx
src/Scenery/tilemgr.cxx
src/Time/tmp.cxx

index 75b2e3afc29851b736e39151e0eca977c05e15c3..478ffa1b1ae50c51ea3c042c5b6b7e56c5a50e2b 100644 (file)
 #endif
 
 #include <sstream>
-#include <simgear/math/vector.hxx>
+#include <simgear/math/SGGeometry.hxx>
 #include <Main/viewer.hxx>
 #include "HUD.hxx"
 
-
 // FIXME
 static float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
 static float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
@@ -424,12 +423,11 @@ void HUD::Ladder::draw(void)
             // however the horizon line should always stay on the horizon.  We
             // project the alpha/beta offset onto the horizon line to get the
             // result we want.
-            sgdVec3 p1; // result
-            sgdVec3 p; sgdSetVec3(p, vel_x, vel_y, 0.0);
-            sgdVec3 p0; sgdSetVec3(p0, 0.0, 0.0, 0.0);
-            sgdVec3 d; sgdSetVec3(d, cos(roll_value), sin(roll_value), 0.0);
-            sgdClosestPointToLine(p1, p, p0, d);
-            glTranslatef(p1[0], p1[1], 0);
+            
+            SGVec3d d(cos(roll_value), sin(roll_value), 0.0);
+            SGRayd r(SGVec3d::zeros(), d);
+            SGVec3d p = r.getClosestPointTo(SGVec3d(vel_x, vel_y, 0.0));
+            glTranslatef(p[0], p[1], 0);
         }
     } else {
         // ladder position is fixed relative to the center of the screen.
index cdf61753007a5848ef5a7fce6a757bec590861ee..f8cc3bebb70f116e2e30072c1215d292d9a3f51c 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <simgear/sg_inlines.h>
 #include <simgear/timing/sg_time.hxx>
-#include <simgear/math/vector.hxx>
 #include <simgear/math/sg_random.h>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/math/sg_geodesy.hxx>
index ffa05fc3f3499b4160771df8af9b43eb1759ee81..d7b51d859cbf3bbdc7d709d7772fd7201bf9a4f3 100644 (file)
@@ -34,7 +34,6 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/constants.h>
 #include <simgear/scene/model/placement.hxx>
-#include <simgear/math/vector.hxx>
 
 #include <Main/globals.hxx>
 #include <Scenery/scenery.hxx>
index a7bbb388bf7bf32802caec5364b072d409b56bd3..e5cd08bbb281bd8b9358b71f0cd468d831bbde06 100644 (file)
@@ -32,7 +32,6 @@
 
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
-#include <simgear/math/vector.hxx>
 #include <simgear/structure/exception.hxx>
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
index 0e04d5b24f4d7919ea8b5abd8d68215c5908915b..3b3ae2a3800ce7373afa5e1119713f0d3e2703cc 100644 (file)
@@ -26,7 +26,6 @@
 #endif
 
 #include <simgear/math/SGMath.hxx>
-#include <simgear/math/vector.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/timing/sg_time.hxx>
 
 #include "sunsolver.hxx"
 #include "tmp.hxx"
 
+/**
+ * Map i.e. project a vector onto a plane.
+ * @param normal (in) normal vector for the plane
+ * @param v0 (in) a point on the plane
+ * @param vec (in) the vector to map onto the plane
+ */
+static SGVec3f map_vec_onto_cur_surface_plane(const SGVec3f& normal, 
+                                             const SGVec3f& v0, 
+                                             const SGVec3f& vec)
+{
+    // calculate a vector "u1" representing the shortest distance from
+    // the plane specified by normal and v0 to a point specified by
+    // "vec".  "u1" represents both the direction and magnitude of
+    // this desired distance.
+
+    // u1 = ( (normal <dot> vec) / (normal <dot> normal) ) * normal
+    SGVec3f u1 = (dot(normal, vec) / dot(normal, normal)) * normal;
+
+    // calculate the vector "v" which is the vector "vec" mapped onto
+    // the plane specified by "normal" and "v0".
+
+    // v = v0 + vec - u1
+    SGVec3f v = v0 + vec - u1;
+    
+    // Calculate the vector "result" which is "v" - "v0" which is a
+    // directional vector pointing from v0 towards v
+
+    // result = v - v0
+    return v - v0;
+}
+
 
 // periodic time updater wrapper
 void fgUpdateLocalTime() {
@@ -158,10 +188,9 @@ void fgUpdateSunPos( void ) {
     // local plane representing "horizontal".
 
     // surface direction to go to head towards sun
-    SGVec3f surface_to_sun;
     SGVec3f view_pos = toVec3f(v->get_view_pos());
-    sgmap_vec_onto_cur_surface_plane( world_up.data(), view_pos.data(),
-                                      to_sun.data(), surface_to_sun.data() );
+    SGVec3f surface_to_sun = map_vec_onto_cur_surface_plane(world_up, view_pos, to_sun);
+    
     surface_to_sun = normalize(surface_to_sun);
     // cout << "(sg) Surface direction to sun is "
     //   << surface_to_sun[0] << ","