2001-01-31 22:57:22 +00:00
|
|
|
// do some test relating to the concept of "up"
|
2006-02-22 20:27:00 +00:00
|
|
|
|
2006-02-22 19:21:29 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
2006-02-22 20:27:00 +00:00
|
|
|
#endif
|
2001-01-31 22:57:22 +00:00
|
|
|
|
2001-03-06 22:36:59 +00:00
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
2008-07-25 18:38:29 +00:00
|
|
|
#include <iostream>
|
2001-01-31 22:57:22 +00:00
|
|
|
|
|
|
|
#include <simgear/constants.h>
|
|
|
|
#include <simgear/math/sg_geodesy.hxx>
|
|
|
|
|
2008-07-29 08:27:48 +00:00
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
2001-06-20 22:22:04 +00:00
|
|
|
|
2001-01-31 22:57:22 +00:00
|
|
|
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;
|
2001-03-24 04:48:44 +00:00
|
|
|
sgGeodToGeoc( lat * SGD_DEGREES_TO_RADIANS, alt, &sl_radius, &lat_geoc );
|
|
|
|
cout << " geoc lat = " << lat_geoc * SGD_RADIANS_TO_DEGREES << endl;
|
2001-01-31 22:57:22 +00:00
|
|
|
|
2001-03-24 04:48:44 +00:00
|
|
|
Point3D pgd( lon * SGD_DEGREES_TO_RADIANS, lat * SGD_DEGREES_TO_RADIANS, 0.0 );
|
2001-01-31 22:57:22 +00:00
|
|
|
Point3D pc = sgGeodToCart( pgd );
|
|
|
|
cout << " cartesian = " << pc << endl;
|
|
|
|
|
2001-01-31 23:07:20 +00:00
|
|
|
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] );
|
2001-01-31 22:57:22 +00:00
|
|
|
cout << " geod up = " << geod_up[0] << ", " << geod_up[1] << ", "
|
|
|
|
<< geod_up[2] << endl;
|
|
|
|
|
2001-01-31 23:07:20 +00:00
|
|
|
sgdMat4 GEOC_UP;
|
|
|
|
sgdVec3 geoc_up;
|
2001-03-24 04:48:44 +00:00
|
|
|
sgdMakeRotMat4( GEOC_UP, lon, 0.0, -lat_geoc * SGD_RADIANS_TO_DEGREES );
|
2001-01-31 23:07:20 +00:00
|
|
|
sgdSetVec3( geoc_up, GEOC_UP[0][0], GEOC_UP[0][1], GEOC_UP[0][2] );
|
2001-01-31 23:04:52 +00:00
|
|
|
cout << " geoc up = " << geoc_up[0] << ", " << geoc_up[1] << ", "
|
|
|
|
<< geoc_up[2] << endl;
|
|
|
|
|
2001-01-31 22:57:22 +00:00
|
|
|
double slope = geod_up[2] / geod_up[0];
|
|
|
|
double intercept = pc.z() - slope * pc.x();
|
|
|
|
cout << " Z intercept (based on geodetic up) = " << intercept << endl;
|
|
|
|
|
2001-01-31 23:04:52 +00:00
|
|
|
slope = geoc_up[2] / geoc_up[0];
|
2001-01-31 22:57:22 +00:00
|
|
|
intercept = pc.z() - slope * pc.x();
|
|
|
|
cout << " Z intercept (based on geocentric up) = " << intercept << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|