From 3240464c7c6a1889910a3cccf02ed8ea968a8b36 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 27 Jan 1999 04:46:14 +0000 Subject: [PATCH] Portability tweaks by Bernie Bright. --- Math/fg_geodesy.cxx | 18 +++++++++++++++--- Math/fg_geodesy.hxx | 16 ++++++++-------- Math/interpolater.cxx | 5 +++-- Math/interpolater.hxx | 5 +++++ Math/point3d.hxx | 32 ++++++++++++++++++++++++++------ Math/polar3d.cxx | 37 +++---------------------------------- Math/polar3d.hxx | 36 +++++++++++++++++++++++++----------- 7 files changed, 85 insertions(+), 64 deletions(-) diff --git a/Math/fg_geodesy.cxx b/Math/fg_geodesy.cxx index b6d1a214..d53689e4 100644 --- a/Math/fg_geodesy.cxx +++ b/Math/fg_geodesy.cxx @@ -8,14 +8,20 @@ // $Id$ // (Log is kept at end of this file) - -#include -#include +#include "Include/compiler.h" +#ifdef FG_HAVE_STD_INCLUDES +# include +# include +#else +# include +# include +#endif #include #include #include +FG_USING_STD(cout); // ONE_SECOND is pi/180/60/60, or about 100 feet at earths' equator #define ONE_SECOND 4.848136811E-6 @@ -156,6 +162,9 @@ void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius, $Header$ $Log$ +Revision 1.5 1999/01/27 04:46:14 curt +Portability tweaks by Bernie Bright. + Revision 1.4 1998/11/20 01:00:36 curt Patch in fgGeoc2Geod() to avoid a floating explosion. point3d.hxx include math.h for FreeBSD @@ -242,6 +251,9 @@ Initial Flight Gear revision. // $Log$ +// Revision 1.5 1999/01/27 04:46:14 curt +// Portability tweaks by Bernie Bright. +// // Revision 1.4 1998/11/20 01:00:36 curt // Patch in fgGeoc2Geod() to avoid a floating explosion. // point3d.hxx include math.h for FreeBSD diff --git a/Math/fg_geodesy.hxx b/Math/fg_geodesy.hxx index 4f7fd267..f863d39d 100644 --- a/Math/fg_geodesy.hxx +++ b/Math/fg_geodesy.hxx @@ -56,8 +56,6 @@ void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius, // a cartesian point inline Point3D fgGeodToCart(const Point3D& geod) { - Point3D cp; - Point3D pp; double gc_lon, gc_lat, sl_radius; // printf("A geodetic point is (%.2f, %.2f, %.2f)\n", @@ -69,12 +67,8 @@ inline Point3D fgGeodToCart(const Point3D& geod) { // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon, // gc_lat, sl_radius+geod[2]); - pp = Point3D(gc_lon, gc_lat, sl_radius + geod.radius()); - cp = fgPolarToCart3d(pp); - - // printf("A cart point is (%.8f, %.8f, %.8f)\n", cp.x, cp.y, cp.z); - - return(cp); + Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius()); + return fgPolarToCart3d(pp); } @@ -120,6 +114,9 @@ inline Point3D fgGeodToCart(const Point3D& geod) { $Header$ $Log$ +Revision 1.4 1999/01/27 04:46:15 curt +Portability tweaks by Bernie Bright. + Revision 1.3 1998/10/18 01:17:11 curt Point3D tweaks. @@ -196,6 +193,9 @@ Initial Flight Gear revision. // $Log$ +// Revision 1.4 1999/01/27 04:46:15 curt +// Portability tweaks by Bernie Bright. +// // Revision 1.3 1998/10/18 01:17:11 curt // Point3D tweaks. // diff --git a/Math/interpolater.cxx b/Math/interpolater.cxx index 394de5a8..6729bcbb 100644 --- a/Math/interpolater.cxx +++ b/Math/interpolater.cxx @@ -36,8 +36,6 @@ // Constructor -- loads the interpolation table from the specified // file fgINTERPTABLE::fgINTERPTABLE( const string& file ) { - string fgfile, line; - FG_LOG( FG_MATH, FG_INFO, "Initializing Interpolator for " << file ); fg_gzifstream in( file ); @@ -103,6 +101,9 @@ fgINTERPTABLE::~fgINTERPTABLE( void ) { // $Log$ +// Revision 1.6 1999/01/27 04:46:16 curt +// Portability tweaks by Bernie Bright. +// // Revision 1.5 1998/11/06 21:17:27 curt // Converted to new logstream debugging facility. This allows release // builds with no messages at all (and no performance impact) by using diff --git a/Math/interpolater.hxx b/Math/interpolater.hxx index 9a7c0bd3..9614faed 100644 --- a/Math/interpolater.hxx +++ b/Math/interpolater.hxx @@ -35,6 +35,8 @@ #include +#include "Include/compiler.h" +FG_USING_STD(string); #define MAX_TABLE_SIZE 32 @@ -61,6 +63,9 @@ public: // $Log$ +// Revision 1.4 1999/01/27 04:46:17 curt +// Portability tweaks by Bernie Bright. +// // Revision 1.3 1998/11/06 21:17:28 curt // Converted to new logstream debugging facility. This allows release // builds with no messages at all (and no performance impact) by using diff --git a/Math/point3d.hxx b/Math/point3d.hxx index a6fe84a3..b1a0ff12 100644 --- a/Math/point3d.hxx +++ b/Math/point3d.hxx @@ -30,15 +30,25 @@ # error This library requires C++ #endif +#include "Include/compiler.h" -#include -#include -#if defined( __BORLANDC__ ) -# define exception c_exception -#elif defined( __FreeBSD__ ) -# include +#ifdef FG_MATH_EXCEPTION_CLASH +# define exception c_exception #endif +#ifdef FG_HAVE_STD_INCLUDES +# include +# include +# include +#else +# include +# include +# include +#endif + +FG_USING_STD(ostream); +FG_USING_STD(istream); + // -rp- assert.h is buggy under MWCWP3, as multiple #include undef assert ! #ifdef __MWERKS__ # define assert(x) @@ -48,6 +58,13 @@ const double fgPoint3_Epsilon = 0.0000001; enum {PX, PY, PZ}; // axes +// Kludge for msvc++ 6.0 - requires forward decls of friend functions. +class Point3D; +istream& operator>> ( istream&, Point3D& ); +ostream& operator<< ( ostream&, const Point3D& ); +Point3D operator- (const Point3D& p); // -p1 +bool operator== (const Point3D& a, const Point3D& b); // p1 == p2? + /////////////////////////// // @@ -303,6 +320,9 @@ Point3D::distance3D(const Point3D& a ) const // $Log$ +// Revision 1.8 1999/01/27 04:46:18 curt +// Portability tweaks by Bernie Bright. +// // Revision 1.7 1999/01/19 20:56:58 curt // MacOS portability changes contributed by "Robert Puyol" // diff --git a/Math/polar3d.cxx b/Math/polar3d.cxx index c0de1e0f..7958a83c 100644 --- a/Math/polar3d.cxx +++ b/Math/polar3d.cxx @@ -30,40 +30,6 @@ #include "polar3d.hxx" -// Convert a polar coordinate to a cartesian coordinate. Lon and Lat -// must be specified in radians. The FG convention is for distances -// to be specified in meters -Point3D fgPolarToCart3d(const Point3D& p) { - Point3D pnew; - double tmp; - - tmp = cos( p.lat() ) * p.radius(); - - pnew = Point3D ( cos( p.lon() ) * tmp, - sin( p.lon() ) * tmp, - sin( p.lat() ) * p.radius() ); - - return pnew; -} - - -// Convert a cartesian coordinate to polar coordinates (lon/lat -// specified in radians. Distances are specified in meters. -Point3D fgCartToPolar3d(const Point3D& cp) { - Point3D pp; - - pp = Point3D( atan2( cp.y(), cp.x() ), - FG_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()) ); - - // printf("lon = %.2f lat = %.2f radius = %.2f\n", - // pp.lon, pp.lat, pp.radius); - - return pp; -} - - // Find the Altitude above the Ellipsoid (WGS84) given the Earth // Centered Cartesian coordinate vector Distances are specified in // meters. @@ -95,6 +61,9 @@ double fgGeodAltFromCart(const Point3D& cp) // $Log$ +// Revision 1.6 1999/01/27 04:46:19 curt +// Portability tweaks by Bernie Bright. +// // Revision 1.5 1998/10/18 01:17:13 curt // Point3D tweaks. // diff --git a/Math/polar3d.hxx b/Math/polar3d.hxx index f7c65516..4118f2d2 100644 --- a/Math/polar3d.hxx +++ b/Math/polar3d.hxx @@ -35,27 +35,41 @@ #include -// Convert a polar coordinate to a cartesian coordinate. Lon and Lat -// must be specified in radians. The FG convention is for distances -// to be specified in meters -Point3D fgPolarToCart3d(const Point3D& p); - - -// Convert a cartesian coordinate to polar coordinates (lon/lat -// specified in radians. Distances are specified in meters. -Point3D fgCartToPolar3d(const Point3D& cp); - - // Find the Altitude above the Ellipsoid (WGS84) given the Earth // Centered Cartesian coordinate vector Distances are specified in // meters. double fgGeodAltFromCart(const Point3D& cp); +// Convert a polar coordinate to a cartesian coordinate. Lon and Lat +// must be specified in radians. The FG convention is for distances +// to be specified in meters +inline Point3D fgPolarToCart3d(const Point3D& p) { + double tmp = cos( p.lat() ) * p.radius(); + + return Point3D( cos( p.lon() ) * tmp, + sin( p.lon() ) * tmp, + sin( p.lat() ) * p.radius() ); +} + + +// Convert a cartesian coordinate to polar coordinates (lon/lat +// specified in radians. Distances are specified in meters. +inline Point3D fgCartToPolar3d(const Point3D& cp) { + return Point3D( atan2( cp.y(), cp.x() ), + FG_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()) ); +} + + #endif // _POLAR_HXX // $Log$ +// Revision 1.5 1999/01/27 04:46:20 curt +// Portability tweaks by Bernie Bright. +// // Revision 1.4 1998/10/16 19:30:07 curt // C++-ified the comments. //