]> git.mxchange.org Git - flightgear.git/commitdiff
Added a test-up program to test the concept of "up".
authorcurt <curt>
Wed, 31 Jan 2001 22:57:22 +0000 (22:57 +0000)
committercurt <curt>
Wed, 31 Jan 2001 22:57:22 +0000 (22:57 +0000)
tests/Makefile.am
tests/test-up.cxx [new file with mode: 0644]

index 8f773fc063e3e1d7cef027adff1b6f42525224d6..cbb62fa1c3cb23c998fcb8c53aed29927828f049 100644 (file)
@@ -1,4 +1,4 @@
-bin_PROGRAMS = est-epsilon gl-info test-mktime
+bin_PROGRAMS = est-epsilon gl-info test-mktime test-up
 
 est_epsilon_SOURCES = est-epsilon.c
 est_epsilon_LDADD = $(base_LIBS)
@@ -8,3 +8,6 @@ gl_info_LDADD = $(opengl_LIBS)
 
 test_mktime_SOURCES = test-mktime.cxx
 test_mktime_LDADD = $(base_LIBS)
+
+test_up_SOURCES = test-up.cxx
+test_up_LDADD = -lsgmath -lsgdebug -lplibsg $(base_LIBS)
diff --git a/tests/test-up.cxx b/tests/test-up.cxx
new file mode 100644 (file)
index 0000000..3623847
--- /dev/null
@@ -0,0 +1,49 @@
+// do some test relating to the concept of "up"
+
+#include <iostream>
+
+#include <plib/sg.h>
+
+#include <simgear/constants.h>
+#include <simgear/math/sg_geodesy.hxx>
+
+int main() {
+    // for each lat/lon given in goedetic coordinates, calculate
+    // geocentric coordinates, cartesian coordinates, the local "up"
+    // vector (based on original geodetic lat/lon), as well as the "Z"
+    // intercept (for which 0 = center of earth)
+
+
+    double lon = 0;
+    double alt = 0;
+
+    for ( double lat = 0; lat <= 90; lat += 5.0 ) {
+       cout << "lon = " << lon << "  geod lat = " << lat;
+
+       double sl_radius, lat_geoc;
+       sgGeodToGeoc( lat * DEG_TO_RAD, alt, &sl_radius, &lat_geoc );
+       cout << "  geoc lat = " << lat_geoc * RAD_TO_DEG << endl;
+
+       Point3D pgd( lon * DEG_TO_RAD, lat * DEG_TO_RAD, 0.0 );
+       Point3D pc = sgGeodToCart( pgd );
+       cout << "  cartesian = " << pc << endl;
+
+       sgMat4 UP;
+       sgVec3 geod_up;
+       sgMakeRotMat4( UP, lon, 0.0, -lat );
+       sgSetVec3( geod_up, UP[0][0], UP[0][1], UP[0][2] );
+       cout << "  geod up = " << geod_up[0] << ", " << geod_up[1] << ", "
+            << geod_up[2] << endl;
+
+       double slope = geod_up[2] / geod_up[0];
+       double intercept = pc.z() - slope * pc.x();
+       cout << "  Z intercept (based on geodetic up) = " << intercept << endl;
+
+       slope = pc.z() / pc.x();
+       intercept = pc.z() - slope * pc.x();
+       cout << "  Z intercept (based on geocentric up) = " << intercept << endl;
+
+   }
+
+    return 0;
+}