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;
// 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;
# 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
// 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()
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 {
// 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()) );
}
} 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;
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
}
if ( sin( dest.x() - start.x() ) < 0 ) {
tc1 = tmp5;
} else {
- tc1 = 2 * SG_PI - tmp5;
+ tc1 = 2 * SGD_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( ( (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;
//
// 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
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;
// 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;
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