// 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
//
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;
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;
// 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;
/** \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.
//
// $Id$
+/** \file constants.h
+ * Various constant definitions.
+ */
+
#ifndef _SG_CONSTANTS_H
#define _SG_CONSTANTS_H
// 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
#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
// 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()
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 {
// 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()) );
}
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;
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
}
if ( sin( dest.x() - start.x() ) < 0 ) {
tc1 = tmp5;
} else {
- tc1 = 2 * FG_PI - tmp5;
+ tc1 = 2 * SG_PI - tmp5;
}
*course = tc1;
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;
//
// 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
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;
// 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;
// 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 );