X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2Ftest-up.cxx;h=5d2d75d0b2bc35b6a0dbdf2a2cc90ac7f5f80771;hb=4ec6810c290ed7ae871a62036936b2733d5995f4;hp=3623847841797e9fdfb4f3af1aa1e97989c5efab;hpb=d48a506721e6122df2506b7b703ec3e8ee345303;p=flightgear.git diff --git a/tests/test-up.cxx b/tests/test-up.cxx index 362384784..5d2d75d0b 100644 --- a/tests/test-up.cxx +++ b/tests/test-up.cxx @@ -1,12 +1,19 @@ // do some test relating to the concept of "up" -#include +#ifdef HAVE_CONFIG_H +# include +#endif + +#include -#include +#include #include #include +using std::cout; +using std::endl; + int main() { // for each lat/lon given in goedetic coordinates, calculate // geocentric coordinates, cartesian coordinates, the local "up" @@ -21,25 +28,32 @@ int main() { 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; + sgGeodToGeoc( lat * SGD_DEGREES_TO_RADIANS, alt, &sl_radius, &lat_geoc ); + cout << " geoc lat = " << lat_geoc * SGD_RADIANS_TO_DEGREES << endl; - Point3D pgd( lon * DEG_TO_RAD, lat * DEG_TO_RAD, 0.0 ); + Point3D pgd( lon * SGD_DEGREES_TO_RADIANS, lat * SGD_DEGREES_TO_RADIANS, 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] ); + sgdMat4 GEOD_UP; + sgdVec3 geod_up; + sgdMakeRotMat4( GEOD_UP, lon, 0.0, -lat ); + sgdSetVec3( geod_up, GEOD_UP[0][0], GEOD_UP[0][1], GEOD_UP[0][2] ); cout << " geod up = " << geod_up[0] << ", " << geod_up[1] << ", " << geod_up[2] << endl; + sgdMat4 GEOC_UP; + sgdVec3 geoc_up; + sgdMakeRotMat4( GEOC_UP, lon, 0.0, -lat_geoc * SGD_RADIANS_TO_DEGREES ); + sgdSetVec3( geoc_up, GEOC_UP[0][0], GEOC_UP[0][1], GEOC_UP[0][2] ); + cout << " geoc up = " << geoc_up[0] << ", " << geoc_up[1] << ", " + << geoc_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(); + slope = geoc_up[2] / geoc_up[0]; intercept = pc.z() - slope * pc.x(); cout << " Z intercept (based on geocentric up) = " << intercept << endl;