Cleaned up a few poluting #defines.

Did some fg -> sg name space updating (lots more to do but we'll get there
  eventually)
This commit is contained in:
curt
2000-09-27 18:00:04 +00:00
parent 453a53b372
commit 7d7e41dacc
9 changed files with 95 additions and 28 deletions
+3 -2
View File
@@ -86,13 +86,14 @@
#define RESQ_FT 437882827922500. // ft #define RESQ_FT 437882827922500. // ft
#define RESQ_M 40680645877797.1344 // meter #define RESQ_M 40680645877797.1344 // meter
#if 0
// Value of earth flattening parameter from ref [8] // Value of earth flattening parameter from ref [8]
// //
// Note: FP = f // Note: FP = f
// E = 1-f // E = 1-f
// EPS = sqrt(1-(1-f)^2) // EPS = sqrt(1-(1-f)^2)
// //
#define FP 0.003352813178 #define FP 0.003352813178
#define E 0.996647186 #define E 0.996647186
#define EPS 0.081819221 #define EPS 0.081819221
@@ -103,7 +104,7 @@
#define MJD0 2415020.0 #define MJD0 2415020.0
#define J2000 (2451545.0 - MJD0) #define J2000 (2451545.0 - MJD0)
#define SIDRATE .9972695677 #define SIDRATE .9972695677
#endif
// Conversions // Conversions
+16 -2
View File
@@ -215,15 +215,29 @@ bool SGSocket::open( SGProtocolDir dir ) {
// this means client for now // this means client for now
sock = make_client_socket(); sock = make_client_socket();
// TODO: check for error. // TODO: check for error.
if ( sock_style == SOCK_DGRAM ) { if ( sock_style == SOCK_DGRAM ) {
// Non-blocking UDP // Non-blocking UDP
nonblock(); nonblock();
} }
} else if ( dir == SG_IO_BI && sock_style == SOCK_STREAM ) {
// this means server for TCP sockets
// Setup socket to listen on. Set "port" before making this
// call. A port of "0" indicates that we want to let the os
// pick any available port.
sock = make_server_socket();
// TODO: check for error.
FG_LOG( FG_IO, FG_INFO, "socket is connected to port = " << port );
// Blocking TCP
// Specify the maximum length of the connection queue
listen( sock, SG_MAX_SOCKET_QUEUE );
} else { } else {
FG_LOG( FG_IO, FG_ALERT, FG_LOG( FG_IO, FG_ALERT,
"Error: bidirection mode not available yet for sockets." ); "Error: bidirection mode not available for UDP sockets." );
return false; return false;
} }
+3 -2
View File
@@ -9,24 +9,25 @@ endif
lib_LIBRARIES = libsgmath.a lib_LIBRARIES = libsgmath.a
include_HEADERS = \ include_HEADERS = \
fg_geodesy.hxx \
fg_memory.h \ fg_memory.h \
fg_random.h \ fg_random.h \
interpolater.hxx \ interpolater.hxx \
leastsqs.hxx \ leastsqs.hxx \
localconsts.hxx \
point3d.hxx \ point3d.hxx \
polar3d.hxx \ polar3d.hxx \
sg_geodesy.hxx \
sg_types.hxx \ sg_types.hxx \
vector.hxx vector.hxx
EXTRA_DIST = linintp2.h linintp2.inl sphrintp.h sphrintp.inl EXTRA_DIST = linintp2.h linintp2.inl sphrintp.h sphrintp.inl
libsgmath_a_SOURCES = \ libsgmath_a_SOURCES = \
fg_geodesy.cxx \
fg_random.c \ fg_random.c \
interpolater.cxx \ interpolater.cxx \
leastsqs.cxx \ leastsqs.cxx \
polar3d.cxx \ polar3d.cxx \
sg_geodesy.cxx \
vector.cxx vector.cxx
INCLUDES += -I$(top_srcdir) $(ZLIB_INCL) INCLUDES += -I$(top_srcdir) $(ZLIB_INCL)
+42
View File
@@ -0,0 +1,42 @@
// localconsts.hxx -- various constant that are shared
//
// Written by Curtis Olson, started September 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// $Id$
#ifndef _SG_LOCAL_CONSTS_HXX
#define _SG_LOCAL_CONSTS_HXX
// Value of earth flattening parameter from ref [8]
//
// Note: FP = f
// E = 1-f
// EPS = sqrt(1-(1-f)^2)
//
static const double FP = 0.003352813178;
static const double E = 0.996647186;
static const double EPS = 0.081819221;
static const double INVG = 0.031080997;
#endif // _SG_LOCAL_CONSTS_HXX
+2
View File
@@ -46,6 +46,8 @@
# include <math.h> # include <math.h>
#endif #endif
#include "localconsts.hxx"
// I don't understand ... <math.h> or <cmath> should be included // I don't understand ... <math.h> or <cmath> should be included
// already depending on how you defined FG_HAVE_STD_INCLUDES, but I // already depending on how you defined FG_HAVE_STD_INCLUDES, but I
// can go ahead and add this -- CLO // can go ahead and add this -- CLO
+4 -4
View File
@@ -40,13 +40,13 @@
// Find the Altitude above the Ellipsoid (WGS84) given the Earth // Find the Altitude above the Ellipsoid (WGS84) given the Earth
// Centered Cartesian coordinate vector Distances are specified in // Centered Cartesian coordinate vector Distances are specified in
// meters. // meters.
double fgGeodAltFromCart(const Point3D& cp); double sgGeodAltFromCart(const Point3D& cp);
// Convert a polar coordinate to a cartesian coordinate. Lon and Lat // Convert a polar coordinate to a cartesian coordinate. Lon and Lat
// must be specified in radians. The FG convention is for distances // must be specified in radians. The SG convention is for distances
// to be specified in meters // to be specified in meters
inline Point3D fgPolarToCart3d(const Point3D& p) { inline Point3D sgPolarToCart3d(const Point3D& p) {
double tmp = cos( p.lat() ) * p.radius(); double tmp = cos( p.lat() ) * p.radius();
return Point3D( cos( p.lon() ) * tmp, return Point3D( cos( p.lon() ) * tmp,
@@ -57,7 +57,7 @@ inline Point3D fgPolarToCart3d(const Point3D& p) {
// Convert a cartesian coordinate to polar coordinates (lon/lat // Convert a cartesian coordinate to polar coordinates (lon/lat
// specified in radians. Distances are specified in meters. // specified in radians. Distances are specified in meters.
inline Point3D fgCartToPolar3d(const Point3D& cp) { inline Point3D sgCartToPolar3d(const Point3D& cp) {
return Point3D( atan2( cp.y(), cp.x() ), return Point3D( atan2( cp.y(), cp.x() ),
FG_PI_2 - FG_PI_2 -
atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() ), atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() ),
@@ -1,4 +1,4 @@
// fg_geodesy.cxx -- routines to convert between geodetic and geocentric // sg_geodesy.cxx -- routines to convert between geodetic and geocentric
// coordinate systems. // coordinate systems.
// //
// Copied and adapted directly from LaRCsim/ls_geodesy.c // Copied and adapted directly from LaRCsim/ls_geodesy.c
@@ -21,7 +21,9 @@
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include "point3d.hxx" #include "point3d.hxx"
#include "fg_geodesy.hxx" #include "sg_geodesy.hxx"
#include "localconsts.hxx"
#ifndef FG_HAVE_NATIVE_SGI_COMPILERS #ifndef FG_HAVE_NATIVE_SGI_COMPILERS
FG_USING_STD(cout); FG_USING_STD(cout);
@@ -31,7 +33,7 @@ FG_USING_STD(cout);
#define ONE_SECOND 4.848136811E-6 #define ONE_SECOND 4.848136811E-6
// fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r) // sgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
// INPUTS: // INPUTS:
// lat_geoc Geocentric latitude, radians, + = North // lat_geoc Geocentric latitude, radians, + = North
// radius C.G. radius to earth center (meters) // radius C.G. radius to earth center (meters)
@@ -43,7 +45,7 @@ FG_USING_STD(cout);
// local vertical (surface normal) of C.G. (meters) // local vertical (surface normal) of C.G. (meters)
void fgGeocToGeod( double lat_geoc, double radius, double void sgGeocToGeod( double lat_geoc, double radius, double
*lat_geod, double *alt, double *sea_level_r ) *lat_geod, double *alt, double *sea_level_r )
{ {
double t_lat, x_alpha, mu_alpha, delt_mu, r_alpha, l_point, rho_alpha; double t_lat, x_alpha, mu_alpha, delt_mu, r_alpha, l_point, rho_alpha;
@@ -89,7 +91,7 @@ void fgGeocToGeod( double lat_geoc, double radius, double
// check for domain error // check for domain error
if ( errno == EDOM ) { if ( errno == EDOM ) {
FG_LOG( FG_GENERAL, FG_ALERT, "Domain ERROR in fgGeocToGeod!!!!" ); FG_LOG( FG_GENERAL, FG_ALERT, "Domain ERROR in sgGeocToGeod!!!!" );
*sea_level_r = 0.0; *sea_level_r = 0.0;
} }
} }
@@ -97,7 +99,7 @@ void fgGeocToGeod( double lat_geoc, double radius, double
} }
// fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc ) // sgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
// INPUTS: // INPUTS:
// lat_geod Geodetic latitude, radians, + = North // lat_geod Geodetic latitude, radians, + = North
// alt C.G. altitude above mean sea level (meters) // alt C.G. altitude above mean sea level (meters)
@@ -109,7 +111,7 @@ void fgGeocToGeod( double lat_geoc, double radius, double
// //
void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius, void sgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
double *lat_geoc ) double *lat_geoc )
{ {
double lambda_sl, sin_lambda_sl, cos_lambda_sl, sin_mu, cos_mu, px, py; double lambda_sl, sin_lambda_sl, cos_lambda_sl, sin_mu, cos_mu, px, py;
@@ -1,4 +1,4 @@
// fg_geodesy.hxx -- routines to convert between geodetic and geocentric // sg_geodesy.hxx -- routines to convert between geodetic and geocentric
// coordinate systems. // coordinate systems.
// //
// Copied and adapted directly from LaRCsim/ls_geodesy.c // Copied and adapted directly from LaRCsim/ls_geodesy.c
@@ -8,8 +8,8 @@
// $Id$ // $Id$
#ifndef _FG_GEODESY_HXX #ifndef _SG_GEODESY_HXX
#define _FG_GEODESY_HXX #define _SG_GEODESY_HXX
#ifndef __cplusplus #ifndef __cplusplus
@@ -21,7 +21,7 @@
#include <simgear/math/polar3d.hxx> #include <simgear/math/polar3d.hxx>
// fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r) // sgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
// INPUTS: // INPUTS:
// lat_geoc Geocentric latitude, radians, + = North // lat_geoc Geocentric latitude, radians, + = North
// radius C.G. radius to earth center (meters) // radius C.G. radius to earth center (meters)
@@ -32,11 +32,11 @@
// sea_level_r radius from earth center to sea level at // sea_level_r radius from earth center to sea level at
// local vertical (surface normal) of C.G. (meters) // local vertical (surface normal) of C.G. (meters)
void fgGeocToGeod( double lat_geoc, double radius, double void sgGeocToGeod( double lat_geoc, double radius, double
*lat_geod, double *alt, double *sea_level_r ); *lat_geod, double *alt, double *sea_level_r );
// fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc ) // sgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
// INPUTS: // INPUTS:
// lat_geod Geodetic latitude, radians, + = North // lat_geod Geodetic latitude, radians, + = North
// alt C.G. altitude above mean sea level (meters) // alt C.G. altitude above mean sea level (meters)
@@ -47,27 +47,27 @@ void fgGeocToGeod( double lat_geoc, double radius, double
// lat_geoc Geocentric latitude, radians, + = North // lat_geoc Geocentric latitude, radians, + = North
// //
void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius, void sgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
double *lat_geoc ); double *lat_geoc );
// convert a geodetic point lon(radians), lat(radians), elev(meter) to // convert a geodetic point lon(radians), lat(radians), elev(meter) to
// a cartesian point // a cartesian point
inline Point3D fgGeodToCart(const Point3D& geod) { inline Point3D sgGeodToCart(const Point3D& geod) {
double gc_lon, gc_lat, sl_radius; double gc_lon, gc_lat, sl_radius;
// printf("A geodetic point is (%.2f, %.2f, %.2f)\n", // printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
// geod[0], geod[1], geod[2]); // geod[0], geod[1], geod[2]);
gc_lon = geod.lon(); gc_lon = geod.lon();
fgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat); sgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
// printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon, // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
// gc_lat, sl_radius+geod[2]); // gc_lat, sl_radius+geod[2]);
Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius()); Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius());
return fgPolarToCart3d(pp); return sgPolarToCart3d(pp);
} }
@@ -172,4 +172,4 @@ $Header$
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
#endif // _FG_GEODESY_HXX #endif // _SG_GEODESY_HXX
+5
View File
@@ -63,6 +63,11 @@
#define RADHR(x) DEGHR(x*RAD_TO_DEG) #define RADHR(x) DEGHR(x*RAD_TO_DEG)
static const double MJD0 = 2415020.0;
static const double J2000 = 2451545.0 - MJD0;
static const double SIDRATE = 0.9972695677;
SGTime::SGTime( double lon, double lat, const string& root ) SGTime::SGTime( double lon, double lat, const string& root )
{ {
FG_LOG( FG_EVENT, FG_INFO, "Initializing Time" ); FG_LOG( FG_EVENT, FG_INFO, "Initializing Time" );