Portability tweaks by Bernie Bright.
This commit is contained in:
parent
a2ffd27b7c
commit
3240464c7c
7 changed files with 85 additions and 64 deletions
|
@ -8,14 +8,20 @@
|
|||
// $Id$
|
||||
// (Log is kept at end of this file)
|
||||
|
||||
|
||||
#include "Include/compiler.h"
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# include <cerrno>
|
||||
#else
|
||||
# include <math.h>
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_geodesy.hxx>
|
||||
#include <Math/point3d.hxx>
|
||||
|
||||
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
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#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
|
||||
|
|
|
@ -30,15 +30,25 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include "Include/compiler.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
#if defined( __BORLANDC__ )
|
||||
#ifdef FG_MATH_EXCEPTION_CLASH
|
||||
# define exception c_exception
|
||||
#elif defined( __FreeBSD__ )
|
||||
#endif
|
||||
|
||||
#ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <iostream>
|
||||
# include <cassert>
|
||||
# include <cmath>
|
||||
#else
|
||||
# include <iostream.h>
|
||||
# include <assert.h>
|
||||
# include <math.h>
|
||||
#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" <puyol@abvent.fr>
|
||||
//
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -35,27 +35,41 @@
|
|||
#include <Math/point3d.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);
|
||||
|
||||
|
||||
// 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.
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue