FG_ to SG_ namespace changes.

This commit is contained in:
curt
2001-03-23 23:18:08 +00:00
parent c16b9ed25b
commit 470d01a508
8 changed files with 37 additions and 31 deletions

View File

@@ -96,21 +96,21 @@ void SGBucket::set_bucket( double dlon, double dlat ) {
// cout << "diff = " << diff << " span = " << span << endl;
if ( (dlon >= 0) || (fabs(diff) < FG_EPSILON) ) {
if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
lon = (int)dlon;
} else {
lon = (int)dlon - 1;
}
// find subdivision or super lon if needed
if ( span < FG_EPSILON ) {
if ( span < SG_EPSILON ) {
// polar cap
lon = 0;
x = 0;
} else if ( span <= 1.0 ) {
x = (int)((dlon - lon) / span);
} else {
if ( (dlon >= 0) || (fabs(diff) < FG_EPSILON) ) {
if ( (dlon >= 0) || (fabs(diff) < SG_EPSILON) ) {
lon = (int)( (int)(lon / span) * span);
} else {
// cout << " lon = " << lon
@@ -128,7 +128,7 @@ void SGBucket::set_bucket( double dlon, double dlat ) {
//
diff = dlat - (double)(int)dlat;
if ( (dlat >= 0) || (fabs(diff) < FG_EPSILON) ) {
if ( (dlat >= 0) || (fabs(diff) < SG_EPSILON) ) {
lat = (int)dlat;
} else {
lat = (int)dlat - 1;
@@ -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 * FG_PI;
double local_perimeter = 2.0 * local_radius * SG_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 * FG_PI;
double perimeter = 2.0 * EQUATORIAL_RADIUS_M * SG_PI;
double degree_height = perimeter / 360.0;
return SG_BUCKET_SPAN * degree_height;

View File

@@ -22,7 +22,9 @@
/** \file compiler.h
* A set of defines to encapsulate compiler and platform differences.
* What this file does.
* Please refer to the source code for full documentation on this file.
*
* Here is a summary of what this file does.
*
* (1) Defines macros for some STL includes which may be affected
* by file name length limitations.

View File

@@ -21,6 +21,10 @@
//
// $Id$
/** \file constants.h
* Various constant definitions.
*/
#ifndef _SG_CONSTANTS_H
#define _SG_CONSTANTS_H
@@ -46,23 +50,23 @@
// PI, only PI, and nothing but PI
#ifdef M_PI
# define FG_PI M_PI
# define SG_PI M_PI
#else
# define FG_PI 3.14159265358979323846
# define SG_PI 3.14159265358979323846
#endif
// 2 * PI
#define FG_2PI 6.28318530717958647692
#define SG_2PI 6.28318530717958647692
// PI / 2
#ifdef M_PI_2
# define FG_PI_2 M_PI_2
# define SG_PI_2 M_PI_2
#else
# define FG_PI_2 1.57079632679489661923
# define SG_PI_2 1.57079632679489661923
#endif
// PI / 4
#define FG_PI_4 0.78539816339744830961
#define SG_PI_4 0.78539816339744830961
#ifndef M_E
# define M_E 2.7182818284590452354
@@ -139,7 +143,7 @@
#define RAD_TO_NM 3437.7467707849392526
// For divide by zero avoidance, this will be close enough to zero
#define FG_EPSILON 0.0000001
#define SG_EPSILON 0.0000001
// Highest binobj format version we know how to read/write. This starts at

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*FG_PI);
geoRa += (2*SG_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 = FG_PI_2 - atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() );
lat_geoc = SG_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( ( (FG_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole
|| ( (FG_PI_2 + lat_geoc) < ONE_SECOND ) ) // near South pole
if( ( (SG_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole
|| ( (SG_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() ),
FG_PI_2 -
SG_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()) );
}
@@ -88,12 +88,12 @@ inline Point3D calc_gc_lon_lat( const Point3D& orig, double course,
result.sety( asin( sin(orig.y()) * cos(dist) +
cos(orig.y()) * sin(dist) * cos(course) ) );
if ( cos(result.y()) < FG_EPSILON ) {
if ( cos(result.y()) < SG_EPSILON ) {
result.setx( orig.x() ); // endpoint a pole
} else {
result.setx(
fmod(orig.x() - asin( sin(course) * sin(dist) /
cos(result.y()) ) + FG_PI, FG_2PI) - FG_PI );
cos(result.y()) ) + SG_PI, SG_2PI) - SG_PI );
}
return result;
@@ -132,10 +132,10 @@ inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest,
double tc1;
if ( cos(start.y()) < FG_EPSILON ) {
if ( cos(start.y()) < SG_EPSILON ) {
// EPS a small number ~ machine precision
if ( start.y() > 0 ) {
tc1 = FG_PI; // starting from N pole
tc1 = SG_PI; // starting from N pole
} else {
tc1 = 0; // starting from S pole
}
@@ -149,7 +149,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 * FG_PI - tmp5;
tc1 = 2 * SG_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( ( (FG_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole
|| ( (FG_PI_2 + lat_geoc) < ONE_SECOND ) ) // near South pole
if( ( (SG_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole
|| ( (SG_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 FG_PI
#define GEOD_INV_PI SG_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 * FG_PI;
double local_perimeter = 2.0 * local_radius * SG_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 * FG_PI;
double perimeter = 2.0 * EQUATORIAL_RADIUS_M * SG_PI;
double degree_height = perimeter / 360.0;
// cout << "degree_height = " << degree_height << endl;
@@ -323,10 +323,10 @@ point_list calc_tex_coords( const SGBucket& b, const point_list& geod_nodes,
// cout << "adjusted_t " << adjusted_t << endl;
}
#endif
if ( adjusted_t.x() < FG_EPSILON ) {
if ( adjusted_t.x() < SG_EPSILON ) {
adjusted_t.setx( 0.0 );
}
if ( adjusted_t.y() < FG_EPSILON ) {
if ( adjusted_t.y() < SG_EPSILON ) {
adjusted_t.sety( 0.0 );
}
adjusted_t.setz( 0.0 );