fgms 0.11.8
The
FlightGear MultiPlayer Server
project
fg_geometry.cxx File Reference
#include <math.h>
#include <strings.h>
#include <assert.h>
#include "fg_geometry.hxx"

Go to the source code of this file.

Macros

#define _EQURAD   (6378137.0)
 
#define E2   fabs(1 - SQUASH*SQUASH)
 

Functions

float Distance (const Point3D &P1, const Point3D &P2)
 Calculate distance of clients. More...
 
Point3D invert (const Point3D &P)
 
t_Point3D length (const Point3D &P)
 Return the length of P. More...
 
Point3D normalize (const Point3D &P)
 Normalize P. More...
 
Point3D operator* (const Point3D &P1, const Point3D &P2)
 
Point3D operator* (const t_Point3D &nV, const Point3D &P1)
 
Point3D operator+ (const Point3D &P1, const Point3D &P2)
 
Point3D operator- (const Point3D &P1, const Point3D &P2)
 
Point3D operator/ (const Point3D &P1, const Point3D &P2)
 
Point3D operator/ (const t_Point3D &nV, const Point3D &P1)
 
Point3D operator^ (const Point3D &P1, const Point3D &P2)
 
void sgCartToGeod (const Point3D &CartPoint, Point3D &GeodPoint)
 Convert a cartexian XYZ coordinate to a geodetic lat/lon/alt. This function is a copy of what's in SimGear, simgear/math/SGGeodesy.cxx. More...
 
void sgGeodToCart (double lat, double lon, double alt, double *xyz)
 Opposite of sgCartToGeod. More...
 
t_Point3D sqr (const Point3D &P)
 
static void surfRZ (double upr, double upz, double *r, double *z)
 This is the inverse of the algorithm in localLat(). It returns the (cylindrical) coordinates of a surface latitude expressed as an "up" unit vector. More...
 

Variables

static double e2 = E2
 
static double e4 = E2*E2
 
static const double POLRAD = 6356752.3142451794975639668
 
static double ra2 = 1/(_EQURAD*_EQURAD)
 
static const double SG_METER_TO_FEET = 3.28083989501312335958
 Meters to Feet. More...
 
static const double SG_NM_TO_METER = 1852.0000
 Nautical Miles in a Meter. More...
 
static const double SG_RAD_TO_NM = 3437.7467707849392526
 Radians To Nautical Miles. More...
 
static const double SGD_PI_2 = 1.57079632679489661923
 PI2. More...
 
static const double SQUASH = 0.9966471893352525192801545
 
static const double STRETCH = 1.0033640898209764189003079
 

Macro Definition Documentation

#define _EQURAD   (6378137.0)

Definition at line 413 of file fg_geometry.cxx.

#define E2   fabs(1 - SQUASH*SQUASH)

Definition at line 414 of file fg_geometry.cxx.

Function Documentation

float Distance ( const Point3D P1,
const Point3D P2 
)

Calculate distance of clients.

Definition at line 365 of file fg_geometry.cxx.

Referenced by FG_SERVER::HandlePacket(), and FG_SERVER::IsInRange().

Point3D invert ( const Point3D P)

Definition at line 304 of file fg_geometry.cxx.

Point3D normalize ( const Point3D P)

Normalize P.

Definition at line 329 of file fg_geometry.cxx.

Point3D operator* ( const Point3D P1,
const Point3D P2 
)

Definition at line 259 of file fg_geometry.cxx.

Point3D operator* ( const t_Point3D nV,
const Point3D P1 
)

Definition at line 286 of file fg_geometry.cxx.

Point3D operator+ ( const Point3D P1,
const Point3D P2 
)

Definition at line 241 of file fg_geometry.cxx.

Point3D operator- ( const Point3D P1,
const Point3D P2 
)

Definition at line 250 of file fg_geometry.cxx.

Point3D operator/ ( const Point3D P1,
const Point3D P2 
)

Definition at line 268 of file fg_geometry.cxx.

Point3D operator/ ( const t_Point3D nV,
const Point3D P1 
)

Definition at line 295 of file fg_geometry.cxx.

Point3D operator^ ( const Point3D P1,
const Point3D P2 
)

Definition at line 277 of file fg_geometry.cxx.

void sgCartToGeod ( const Point3D CartPoint,
Point3D GeodPoint 
)

Convert a cartexian XYZ coordinate to a geodetic lat/lon/alt. This function is a copy of what's in SimGear, simgear/math/SGGeodesy.cxx.

Definition at line 425 of file fg_geometry.cxx.

Referenced by FG_CLI::cmd_user_show(), FG_SERVER::HandleTelnet(), and FG_SERVER::UpdateTracker().

void sgGeodToCart ( double  lat,
double  lon,
double  alt,
double *  xyz 
)

Opposite of sgCartToGeod.

Definition at line 458 of file fg_geometry.cxx.

t_Point3D sqr ( const Point3D P)

Definition at line 313 of file fg_geometry.cxx.

static void surfRZ ( double  upr,
double  upz,
double *  r,
double *  z 
)
static

This is the inverse of the algorithm in localLat(). It returns the (cylindrical) coordinates of a surface latitude expressed as an "up" unit vector.

Definition at line 382 of file fg_geometry.cxx.

Referenced by sgGeodToCart().

Variable Documentation

double e2 = E2
static

Definition at line 416 of file fg_geometry.cxx.

Referenced by sgCartToGeod().

double e4 = E2*E2
static

Definition at line 417 of file fg_geometry.cxx.

Referenced by sgCartToGeod().

const double POLRAD = 6356752.3142451794975639668
static

Definition at line 41 of file fg_geometry.cxx.

Referenced by surfRZ().

double ra2 = 1/(_EQURAD*_EQURAD)
static

Definition at line 415 of file fg_geometry.cxx.

Referenced by sgCartToGeod().

const double SG_METER_TO_FEET = 3.28083989501312335958
static

Meters to Feet.

Definition at line 50 of file fg_geometry.cxx.

Referenced by sgCartToGeod().

const double SG_NM_TO_METER = 1852.0000
static

Nautical Miles in a Meter.

Definition at line 47 of file fg_geometry.cxx.

Referenced by Distance().

const double SG_RAD_TO_NM = 3437.7467707849392526
static

Radians To Nautical Miles.

Definition at line 44 of file fg_geometry.cxx.

const double SGD_PI_2 = 1.57079632679489661923
static

PI2.

Definition at line 53 of file fg_geometry.cxx.

Referenced by Point3D::CartToPolar().

const double SQUASH = 0.9966471893352525192801545
static

High-precision versions of the above produced with an arbitrary precision calculator (the compiler might lose a few bits in the FPU operations). These are specified to 81 bits of mantissa, which is higher than any FPU known to me:

Definition at line 39 of file fg_geometry.cxx.

Referenced by surfRZ().

const double STRETCH = 1.0033640898209764189003079
static

Definition at line 40 of file fg_geometry.cxx.

Referenced by surfRZ().