Trying to sort out name space confusing with SG_PI and SGD_PI and varients.

This commit is contained in:
curt 2001-03-23 23:39:25 +00:00
parent 470d01a508
commit 0e8c010645
8 changed files with 25 additions and 27 deletions

View File

@ -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;

View File

@ -45,28 +45,25 @@
# include <math.h>
#endif
#include <plib/sg.h>
// 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

View File

@ -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()

View File

@ -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 {

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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