]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/HUD/HUD_ladder.cxx
Navradio: provide property is-localizer-frequency
[flightgear.git] / src / Instrumentation / HUD / HUD_ladder.cxx
index 75b2e3afc29851b736e39151e0eca977c05e15c3..9b4ba108461dbec5cd959cce462020e94b0fffbb 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"); }
@@ -49,7 +48,7 @@ HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
     _roll(n->getNode("roll-input", false)),
     _width_units(int(n->getFloatValue("display-span"))),
     _div_units(int(fabs(n->getFloatValue("divisions")))),
-    _scr_hole(fabsf(n->getFloatValue("screen-hole")) * 0.5f),
+    _scr_hole(fabs(n->getFloatValue("screen-hole")) * 0.5f),
     _zero_bar_overlength(n->getFloatValue("zero-bar-overlength", 10)),
     _dive_bar_angle(n->getBoolValue("enable-dive-bar-angle")),
     _tick_length(n->getFloatValue("tick-length")),
@@ -139,7 +138,7 @@ void HUD::Ladder::draw(void)
     //****************************************************************
     //velocity vector reticle - computations
     float xvvr, /* yvvr, */ Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
-    float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
+    float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope; //, t1;
     float up_vel, ground_vel, actslope = 0.0, psi = 0.0;
     float vel_x = 0.0, vel_y = 0.0, drift;
     float alpha;
@@ -321,10 +320,10 @@ void HUD::Ladder::draw(void)
 
     if (_energy_marker) {
         if (total_vel < 5.0) {
-            t1 = 0;
+//            t1 = 0;
             t2 = 0;
         } else {
-            t1 = up_vel / total_vel;
+//            t1 = up_vel / total_vel;
             t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
         }
         pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
@@ -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.