From: curt Date: Fri, 23 Mar 2001 23:39:25 +0000 (+0000) Subject: Trying to sort out name space confusing with SG_PI and SGD_PI and varients. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0e8c0106451afb543b9c4d4a74abdc90f09141e3;p=simgear.git Trying to sort out name space confusing with SG_PI and SGD_PI and varients. --- diff --git a/simgear/bucket/newbucket.cxx b/simgear/bucket/newbucket.cxx index 8e334d8d..a86f01ac 100644 --- a/simgear/bucket/newbucket.cxx +++ b/simgear/bucket/newbucket.cxx @@ -209,7 +209,7 @@ double SGBucket::get_width_m() const { double clat_rad = clat * DEG_TO_RAD; double cos_lat = cos( clat_rad ); double local_radius = cos_lat * EQUATORIAL_RADIUS_M; - double local_perimeter = 2.0 * local_radius * SG_PI; + double local_perimeter = 2.0 * local_radius * SGD_PI; double degree_width = local_perimeter / 360.0; return sg_bucket_span( get_center_lat() ) * degree_width; @@ -218,7 +218,7 @@ double SGBucket::get_width_m() const { // return height of the tile in meters double SGBucket::get_height_m() const { - double perimeter = 2.0 * EQUATORIAL_RADIUS_M * SG_PI; + double perimeter = 2.0 * EQUATORIAL_RADIUS_M * SGD_PI; double degree_height = perimeter / 360.0; return SG_BUCKET_SPAN * degree_height; diff --git a/simgear/constants.h b/simgear/constants.h index f6d73d7a..3558b121 100644 --- a/simgear/constants.h +++ b/simgear/constants.h @@ -45,28 +45,25 @@ # include #endif +#include + // Make sure PI is defined in its various forms -// PI, only PI, and nothing but PI -#ifdef M_PI -# define SG_PI M_PI -#else -# define SG_PI 3.14159265358979323846 -#endif +// SG_PI and SGD_PI (float and double) come from plib/sg.h // 2 * PI -#define SG_2PI 6.28318530717958647692 +#define SGD_2PI 6.28318530717958647692 // PI / 2 #ifdef M_PI_2 -# define SG_PI_2 M_PI_2 +# define SGD_PI_2 M_PI_2 #else -# define SG_PI_2 1.57079632679489661923 +# define SGD_PI_2 1.57079632679489661923 #endif // PI / 4 -#define SG_PI_4 0.78539816339744830961 +#define SGD_PI_4 0.78539816339744830961 #ifndef M_E # define M_E 2.7182818284590452354 diff --git a/simgear/ephemeris/moonpos.cxx b/simgear/ephemeris/moonpos.cxx index 07c4e790..4a348316 100644 --- a/simgear/ephemeris/moonpos.cxx +++ b/simgear/ephemeris/moonpos.cxx @@ -173,7 +173,7 @@ void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) // FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho ); if (geoRa < 0) - geoRa += (2*SG_PI); + geoRa += (2*SGD_PI); HA = lst - (3.8197186 * geoRa); /* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst() diff --git a/simgear/math/polar3d.cxx b/simgear/math/polar3d.cxx index 7a36e96d..b3c0fe60 100644 --- a/simgear/math/polar3d.cxx +++ b/simgear/math/polar3d.cxx @@ -39,11 +39,11 @@ double fgGeodAltFromCart(const Point3D& cp) double lat_geoc, radius; double result; - lat_geoc = SG_PI_2 - atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() ); + lat_geoc = SGD_PI_2 - atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() ); radius = sqrt( cp.x()*cp.x() + cp.y()*cp.y() + cp.z()*cp.z() ); - if( ( (SG_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole - || ( (SG_PI_2 + lat_geoc) < ONE_SECOND ) ) // near South pole + if( ( (SGD_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole + || ( (SGD_PI_2 + lat_geoc) < ONE_SECOND ) ) // near South pole { result = radius - EQUATORIAL_RADIUS_M*E; } else { diff --git a/simgear/math/polar3d.hxx b/simgear/math/polar3d.hxx index 6458cc1d..0c91bd4f 100644 --- a/simgear/math/polar3d.hxx +++ b/simgear/math/polar3d.hxx @@ -59,7 +59,7 @@ inline Point3D sgPolarToCart3d(const Point3D& p) { // specified in radians. Distances are specified in meters. inline Point3D sgCartToPolar3d(const Point3D& cp) { return Point3D( atan2( cp.y(), cp.x() ), - SG_PI_2 - + SGD_PI_2 - atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() ), sqrt(cp.x()*cp.x() + cp.y()*cp.y() + cp.z()*cp.z()) ); } @@ -93,7 +93,8 @@ inline Point3D calc_gc_lon_lat( const Point3D& orig, double course, } else { result.setx( fmod(orig.x() - asin( sin(course) * sin(dist) / - cos(result.y()) ) + SG_PI, SG_2PI) - SG_PI ); + cos(result.y()) ) + + SGD_PI, SGD_2PI) - SGD_PI ); } return result; @@ -135,7 +136,7 @@ inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest, if ( cos(start.y()) < SG_EPSILON ) { // EPS a small number ~ machine precision if ( start.y() > 0 ) { - tc1 = SG_PI; // starting from N pole + tc1 = SGD_PI; // starting from N pole } else { tc1 = 0; // starting from S pole } @@ -149,7 +150,7 @@ inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest, if ( sin( dest.x() - start.x() ) < 0 ) { tc1 = tmp5; } else { - tc1 = 2 * SG_PI - tmp5; + tc1 = 2 * SGD_PI - tmp5; } *course = tc1; diff --git a/simgear/math/sg_geodesy.cxx b/simgear/math/sg_geodesy.cxx index 8969d713..f26c0e93 100644 --- a/simgear/math/sg_geodesy.cxx +++ b/simgear/math/sg_geodesy.cxx @@ -60,8 +60,8 @@ void sgGeocToGeod( double lat_geoc, double radius, double double t_lat, x_alpha, mu_alpha, delt_mu, r_alpha, l_point, rho_alpha; double sin_mu_a, denom,delt_lambda, lambda_sl, sin_lambda_sl; - if( ( (SG_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole - || ( (SG_PI_2 + lat_geoc) < ONE_SECOND ) ) // near South pole + if( ( (SGD_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole + || ( (SGD_PI_2 + lat_geoc) < ONE_SECOND ) ) // near South pole { *lat_geod = lat_geoc; *sea_level_r = EQUATORIAL_RADIUS_M*E; @@ -180,7 +180,7 @@ void sgGeodToGeoc( double lat_geod, double alt, double *sl_radius, // // modified for FlightGear to use WGS84 only -- Norman Vine -#define GEOD_INV_PI SG_PI +#define GEOD_INV_PI SGD_PI // s == distance // az = azimuth diff --git a/simgear/misc/texcoord.cxx b/simgear/misc/texcoord.cxx index f428cc92..4469c555 100644 --- a/simgear/misc/texcoord.cxx +++ b/simgear/misc/texcoord.cxx @@ -181,7 +181,7 @@ point_list calc_tex_coords( const SGBucket& b, const point_list& geod_nodes, double clat_rad = clat * DEG_TO_RAD; double cos_lat = cos( clat_rad ); double local_radius = cos_lat * EQUATORIAL_RADIUS_M; - double local_perimeter = 2.0 * local_radius * SG_PI; + double local_perimeter = 2.0 * local_radius * SGD_PI; double degree_width = local_perimeter / 360.0; // cout << "clat = " << clat << endl; @@ -191,7 +191,7 @@ point_list calc_tex_coords( const SGBucket& b, const point_list& geod_nodes, // cout << "local_perimeter = " << local_perimeter << endl; // cout << "degree_width = " << degree_width << endl; - double perimeter = 2.0 * EQUATORIAL_RADIUS_M * SG_PI; + double perimeter = 2.0 * EQUATORIAL_RADIUS_M * SGD_PI; double degree_height = perimeter / 360.0; // cout << "degree_height = " << degree_height << endl; diff --git a/simgear/sky/sphere.cxx b/simgear/sky/sphere.cxx index f16bcf4f..877489fc 100644 --- a/simgear/sky/sphere.cxx +++ b/simgear/sky/sphere.cxx @@ -54,8 +54,8 @@ ssgBranch *ssgMakeSphere( ssgSimpleState *state, ssgColourArray *cl, sgVec2 vec2; sgVec3 vec3; - drho = SG_PI / (float) stacks; - dtheta = 2.0 * SG_PI / (float) slices; + drho = SGD_PI / (float) stacks; + dtheta = 2.0 * SGD_PI / (float) slices; /* texturing: s goes from 0.0/0.25/0.5/0.75/1.0 at +y/+x/-y/-x/+y axis t goes from -1.0/+1.0 at z = -radius/+radius (linear along