From: James Turner Date: Fri, 23 Jul 2010 12:26:07 +0000 (+0100) Subject: Remove all (2) uses of simgear/math/vector.h from FlightGear. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9604908a8d38767345410447b75a13582158128e;p=flightgear.git Remove all (2) uses of simgear/math/vector.h from FlightGear. --- diff --git a/src/Instrumentation/HUD/HUD_ladder.cxx b/src/Instrumentation/HUD/HUD_ladder.cxx index 75b2e3afc..478ffa1b1 100644 --- a/src/Instrumentation/HUD/HUD_ladder.cxx +++ b/src/Instrumentation/HUD/HUD_ladder.cxx @@ -24,11 +24,10 @@ #endif #include -#include +#include #include
#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. diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index cdf617530..f8cc3bebb 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx index ffa05fc3f..d7b51d859 100644 --- a/src/Main/viewer.cxx +++ b/src/Main/viewer.cxx @@ -34,7 +34,6 @@ #include #include #include -#include #include
#include diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index a7bbb388b..e5cd08bbb 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include diff --git a/src/Time/tmp.cxx b/src/Time/tmp.cxx index 0e04d5b24..3b3ae2a38 100644 --- a/src/Time/tmp.cxx +++ b/src/Time/tmp.cxx @@ -26,7 +26,6 @@ #endif #include -#include #include #include @@ -39,6 +38,37 @@ #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 vec) / (normal 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] << ","