*
* 3 bits - to represent x (0 to 7)
* 3 bits - to represent y (0 to 7)
+ * @return tile index
*/
inline long int gen_index() const {
return ((lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x;
/**
* Generate the unique scenery tile index for this bucket in ascii
* string form.
+ * @return tile index in string form
*/
inline string gen_index_str() const {
char tmp[20];
/**
* Build the base path name for this bucket.
+ * @return base path in string form
*/
string gen_base_path() const;
/**
- * Return the center lon of a tile.
+ * @return the center lon of a tile.
*/
inline double get_center_lon() const {
double span = sg_bucket_span( lat + y / 8.0 + SG_HALF_BUCKET_SPAN );
}
/**
- * Return the center lat of a tile.
+ * @return the center lat of a tile.
*/
inline double get_center_lat() const {
return lat + y / 8.0 + SG_HALF_BUCKET_SPAN;
}
/**
- * Return width of the tile in degrees.
+ * @return the width of the tile in degrees.
*/
double get_width() const;
/**
- * Return height of the tile in degrees.
+ * @return the height of the tile in degrees.
*/
double get_height() const;
/**
- * Return width of the tile in meters.
+ * @return the width of the tile in meters.
*/
double get_width_m() const;
/**
- * Return height of the tile in meters.
+ * @return the height of the tile in meters.
*/
double get_height_m() const;
// Informational methods.
/**
- * Return the lon of the lower left corner of this tile.
+ * @return the lon of the lower left corner of this tile.
*/
inline int get_lon() const { return lon; }
/**
- * Return the lat of the lower left corner of this tile.
+ * @return the lat of the lower left corner of this tile.
*/
inline int get_lat() const { return lat; }
/**
- * Return the x coord within the 1x1 degree chunk this tile.
+ * @return the x coord within the 1x1 degree chunk this tile.
*/
inline int get_x() const { return x; }
/**
- * Return the y coord within the 1x1 degree chunk this tile.
+ * @return the y coord within the 1x1 degree chunk this tile.
*/
inline int get_y() const { return y; }
/**
+ * \relates SGBucket
* Return the bucket which is offset from the specified dlon, dlat by
* the specified tile units in the X & Y direction.
* @param dlon starting lon in degrees
* @param dlat starting lat in degrees
* @param x number of bucket units to offset in x (lon) direction
* @param y number of bucket units to offset in y (lat) direction
+ * @return offset bucket
*/
SGBucket sgBucketOffset( double dlon, double dlat, int x, int y );
/**
+ * \relates SGBucket
* Calculate the offset between two buckets (in quantity of buckets).
* @param b1 bucket 1
* @param b2 bucket 2
* Compare two bucket structures for equality.
* @param b1 bucket 1
* @param b2 bucket 2
+ * @return comparison result
*/
inline bool
operator== ( const SGBucket& b1, const SGBucket& b2 )
// logbuf( streambuf* sb ) : sbuf(sb) {}
/** Constructor */
logbuf();
+
/** Destructor */
~logbuf();
- /** Is logging enabled? */
+ /**
+ * Is logging enabled?
+ * @return true or false*/
bool enabled() { return logging_enabled; }
/**
/**
+ * \relates logstream
* Return the one and only logstream instance.
* We use a function instead of a global object so we are assured that cerr
* has been initialised.
+ * @return current logstream
*/
inline logstream&
sglog()
void update(double mjd, double lst, double lat);
/**
- * Returns a pointer to a Star class containing all the positional
+ * @return a pointer to a Star class containing all the positional
* information for Earth's Sun.
*/
inline Star *get_sun() const { return our_sun; }
- /** Returns the right ascension of the Sun. */
+ /** @return the right ascension of the Sun. */
inline double getSunRightAscension() const {
return our_sun->getRightAscension();
}
- /** Returns the declination of the Sun. */
+ /** @return the declination of the Sun. */
inline double getSunDeclination() const {
return our_sun->getDeclination();
}
/**
- * Returns a pointer to a Moon class containing all the positional
+ * @return a pointer to a Moon class containing all the positional
* information for Earth's Moon.
*/
inline MoonPos *get_moon() const { return moon; }
- /** Returns the right ascension of the Moon. */
+ /** @return the right ascension of the Moon. */
inline double getMoonRightAscension() const {
return moon->getRightAscension();
}
- /** Returns the declination of the Moon. */
+ /** @return the declination of the Moon. */
inline double getMoonDeclination() const {
return moon->getDeclination();
}
- /** Returns the numbers of defined planets. */
+ /** @return the numbers of defined planets. */
inline int getNumPlanets() const { return nplanets; }
/**
* the ``sg'' package.) An sgdVec3 is a 3 element double
* array. The first element is the right ascension of the planet,
* the second is the declination, and the third is the magnitude.
+ * @return planets array
*/
inline sgdVec3 *getPlanets() { return planets; }
- /** Returns the numbers of defined stars. */
+ /** @return the numbers of defined stars. */
inline int getNumStars() const { return stars->getNumStars(); }
/**
* format. An The first element of the sgdVec3 is the right
* ascension of the planet, the second is the declination, and the
* third is the magnitude.
+ * @returns star array
*/
inline sgdVec3 *getStars() { return stars->getStars(); }
};
* - SG_IO_BI - data will be flowing in both directions.
* - SG_IO_NONE - data will not be flowing in either direction.
* This is here for the sake of completeness.
+ * @return result of open
*/
virtual bool open( const SGProtocolDir d );
* accomodate your input message
* @param buf a char pointer to your input buffer
* @param length max number of bytes to read
+ * @return number of bytes read
*/
virtual int read( char *buf, int length );
* stop at the first end of line encountered in the input buffer.
* @param buf a char pointer to your input buffer
* @param length max number of bytes to read
+ * @return number of bytes read
*/
virtual int readline( char *buf, int length );
* written out. The number of bytes written is returned.
* @param buf a char pointer to your output buffer
* @param length number of bytes to write
+ * @return number of bytes written
*/
virtual int write( const char *buf, const int length );
* calculate the length of a null terminated character array and
* write it to the output channel.
* @param buf a char pointer to your output buffer
+ * @return number of bytes written
*/
virtual int writestring( const char *str );
* The close() method is modeled after the close() Unix system
* call and will close an open device. You should call this method
* when you are done using your IO class, before it is destructed.
+ * @return result of close
*/
virtual bool close();
-// sg_binobj.hxx -- routines to read and write low level flightgear 3d objects
-//
+/**
+ * \file sg_binobj.hxx
+ * Routines to read and write the low level (binary) simgear 3d object format.
+ */
+
// Written by Curtis Olson, started January 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
-//
#ifndef _SG_BINOBJ_HXX
+/** STL Structure used to store object information */
typedef vector < int_list > group_list;
typedef group_list::iterator group_list_iterator;
typedef group_list::const_iterator const_group_list_iterator;
+/** Magic Number for our file format */
#define SG_FILE_MAGIC_NUMBER ( ('S'<<24) + ('G'<<16) + SG_BINOBJ_VERSION )
-/*
- scenery-file: magic, nobjects, object+
- magic: "TG" + version
- object: obj_typecode, nproperties, nelements, property+, element+
- element: nbytes, BYTE+
- property: prop_typecode, nbytes, BYTE+
- obj_typecode: bounding sphere | vertices | normals | texcoords | triangles |
- fans | strips
- prop_typecode: material_name | ???
- nelements: SHORT (Gives us 65536 which ought to be enough, right?)
- nproperties: SHORT
- *_typecode: CHAR
- nbytes: INTEGER (If we used short here that would mean 65536 bytes = 16384
- floats = 5461 vertices which is not enough for future
- growth)
- vertex: FLOAT, FLOAT, FLOAT
+/**
+ * A class to manipulate the simgear 3d object format.
+ * This class provides functionality to both read and write the binary format.
+ *
+ * Here is a really quick overview of the file syntax:
+ *
+ * - scenery-file: magic, nobjects, object+
+ *
+ * - magic: "TG" + version
+ *
+ * - object: obj_typecode, nproperties, nelements, property+, element+
+ *
+ * - element: nbytes, BYTE+
+ *
+ * - property: prop_typecode, nbytes, BYTE+
+ *
+ * - obj_typecode: bounding sphere | vertices | normals | texcoords |
+ * triangles | fans | strips
+ *
+ * - prop_typecode: material_name | ???
+ *
+ * - nelements: SHORT (Gives us 65536 which ought to be enough, right?)
+ *
+ * - nproperties: SHORT
+ *
+ * - *_typecode: CHAR
+ *
+ * - nbytes: INTEGER (If we used short here that would mean 65536 bytes = 16384
+ * floats = 5461 vertices which is not enough for future
+ * growth)
+ *
+ * - vertex: FLOAT, FLOAT, FLOAT
*/
-
-
class SGBinObject {
Point3D gbs_center;
float gbs_radius;
inline string_list get_fan_materials() const { return fan_materials; }
inline void set_fan_materials( string_list s ) { fan_materials = s; }
- // read a binary file object and populate the provided structures.
+ /**
+ * Read a binary file object and populate the provided structures.
+ * @param file input file name
+ * @return result of read
+ */
bool read_bin( const string& file );
- // write out the structures to a binary file. We assume that the
- // groups come to us sorted by material property. If not, things
- // don't break, but the result won't be as optimal.
+ /**
+ * Write out the structures to a binary file. We assume that the
+ * groups come to us sorted by material property. If not, things
+ * don't break, but the result won't be as optimal.
+ * @param base name of output path
+ * @param name name of output file
+ * @param b bucket for object location
+ * @return result of write
+ */
bool write_bin( const string& base, const string& name, const SGBucket& b );
- // write out the structures to an ASCII file. We assume that the
- // groups come to us sorted by material property. If not, things
- // don't break, but the result won't be as optimal.
+ /**
+ * Write out the structures to an ASCII file. We assume that the
+ * groups come to us sorted by material property. If not, things
+ * don't break, but the result won't be as optimal.
+ * @param base name of output path
+ * @param name name of output file
+ * @param b bucket for object location
+ * @return result of write
+ */
bool write_ascii( const string& base, const string& name,
const SGBucket& b );
};
-// calculate the bounding sphere. Center is the center of the
-// tile and zero elevation
+/**
+ * \relates SGBinObject
+ * Calculate the bounding sphere of a set of nodes.
+ * Center is the center of the tile and zero elevation.
+ * @param center center of our bounding radius
+ * @param wgs84_nodes list of points in wgs84 coordinates
+ * @return radius
+ */
double sgCalcBoundingRadius( Point3D center, point_list& wgs84_nodes );
// close file
bool close();
- /** Return the name of the file being manipulated. */
+ /** @return the name of the file being manipulated. */
inline string get_file_name() const { return file_name; }
};
// close port
bool close();
- /** Return the serial port device name */
+ /** @return the serial port device name */
inline string get_device() const { return device; }
- /** Return the baud rate */
+ /** @return the baud rate */
inline string get_baud() const { return baud; }
};
// close file
bool close();
- /** Enable non-blocking mode. */
+ /**
+ * Enable non-blocking mode.
+ * @return success/failure
+ */
bool nonblock();
- /** Return the remote host name */
+ /** @return the remote host name */
inline string get_hostname() const { return hostname; }
- /** Return the port number (in string form) */
+ /** @return the port number (in string form) */
inline string get_port_str() const { return port_str; }
};
-// magvar.hxx -- magnetic variation wrapper class
-//
+/**
+ * \file magvar.hxx
+ * Magnetic variation wrapper class.
+ */
+
// Written by Curtis Olson, started July 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
# include <config.h>
#endif
-
+/**
+ * Magnetic variation wrapper class.
+ *
+ * The SGMagVar class calculates the magnetic variation and dip for
+ * any position, altitude, and time. It is a complete
+ * re-implimentation of the NIMA WMM 2000 (not derived from their demo
+ * code.)
+ *
+ * The SGMagVar class is really a simple wrapper around the core Ed
+ * Williams code which does all the hard work. This class allows you
+ * to crunch the math once and then do multiple polls of the
+ * data. However, if your position, altitude, or time has changed
+ * significantly, you should call the update() method to recrunch new
+ * numbers.
+ */
class SGMagVar {
private:
public:
+ /**
+ * This creates an instance of the SGMagVar object.
+ * You must call the update() method before any queries will be valid.
+ */
SGMagVar();
+
+ /** Destructor */
~SGMagVar();
- // recalculate the magnetic offset and dip
+ /** Recalculate the magnetic offset and dip.
+ * The update() method requires you to pass in your position and
+ * the julian date. Lon and lat are specified in radians, altitude
+ * is specified in meters. Julian date can be conveniently
+ * calculated by using an instance of the SGTime class.
+ * @param lon longitude in radians
+ * @param lat latitude in radians
+ * @param alt_m altitude above sea level in meters
+ * @param jd julian date
+ */
void update( double lon, double lat, double alt_m, double jd );
+ /** @return the current magnetic variation in radians. */
double get_magvar() const { return magvar; }
+
+ /** @return the current magnetic dip in radians. */
double get_magdip() const { return magdip; }
};
-// lookup the magvar for any arbitrary location (doesn't save state
-// and note that this is a fair amount of cpu work)
+/**
+ * \relates SGMagVar
+ * Lookup the magvar for any arbitrary location (This function doesn't
+ * save state like the SGMagVar class. This function triggers a fair
+ * amount of CPU work, so use it cautiously.
+ * @return the magvar in radians
+ */
double sgGetMagVar( double lon, double lat, double alt_m, double jd );
lib_LIBRARIES = libsgmath.a
include_HEADERS = \
- fg_memory.h \
interpolater.hxx \
leastsqs.hxx \
localconsts.hxx \
point3d.hxx \
polar3d.hxx \
sg_geodesy.hxx \
+ sg_memory.h \
sg_random.h \
sg_types.hxx \
vector.hxx
+++ /dev/null
-// fg_memory.h -- memcpy/bcopy portability declarations
-//
-// 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 _FG_MEMORY_H
-#define _FG_MEMORY_H
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef HAVE_MEMCPY
-
-# ifdef HAVE_MEMORY_H
-# include <memory.h>
-# endif
-
-# define fgmemcmp memcmp
-# define fgmemcpy memcpy
-# define fgmemzero(dest,len) memset(dest,0,len)
-
-#elif defined(HAVE_BCOPY)
-
-# define fgmemcmp bcmp
-# define fgmemcpy(dest,src,n) bcopy(src,dest,n)
-# define fgmemzero bzero
-
-#else
-
-/*
- * Neither memcpy() or bcopy() available.
- * Use substitutes provided be zlib.
- */
-
-# include <zutil.h>
-# define fgmemcmp zmemcmp
-# define fgmemcpy zmemcpy
-# define fgmemzero zmemzero
-
-#endif
-
-#endif // _FG_MEMORY_H
-
-
// Destructor
-SGInterpTable::~SGInterpTable( void ) {
+SGInterpTable::~SGInterpTable() {
}
-//
-// interpolater.hxx -- routines to handle linear interpolation from a table of
-// x,y The table must be sorted by "x" in ascending order
-//
+/**
+ * \file interpolater.hxx
+ * Routines to handle linear interpolation from a table of x,y The
+ * table must be sorted by "x" in ascending order
+ */
+
// Written by Curtis Olson, started April 1998.
//
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
#define MAX_TABLE_SIZE 32
-
+/**
+ * A class that provids a simple linear 2d interpolation lookup table.
+ * The actual table is expected to be loaded from a file. The
+ * independant variable must be strictly ascending. The dependent
+ * variable can be anything.
+ */
class SGInterpTable {
int size;
double table[MAX_TABLE_SIZE][2];
public:
- // Constructor -- loads the interpolation table from the specified
- // file
+ /**
+ * Constructor. Loads the interpolation table from the specified file.
+ * @param file name of interpolation file
+ */
SGInterpTable( const string& file );
- // Given an x value, linearly interpolate the y value from the table
+ /**
+ * Given an x value, linearly interpolate the y value from the table.
+ * @param x independent variable
+ * @return interpolated dependent variable
+ */
double interpolate(double x);
- // Destructor
- ~SGInterpTable( void );
+ /** Destructor */
+ ~SGInterpTable();
};
-// leastsqs.h -- Implements a simple linear least squares best fit routine
-//
+/**
+ * \file leastsqs.hxx
+ * Implements a simple linear least squares best fit routine.
+ */
+
// Written by Curtis Olson, started September 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Boston, MA 02111-1307, USA.
//
// $Id$
-///
#ifndef _LEASTSQS_H
#endif
-/*
-Least squares fit:
-
-y = b0 + b1x
+/**
+Classical least squares fit:
- n*sum(xi*yi) - (sum(xi)*sum(yi))
-b1 = --------------------------------
- n*sum(xi^2) - (sum(xi))^2
+\f[
+ y = b_0 + b_1 * x
+\f]
+\f[
+ b_1 = \frac{n * \sum_0^i (x_i*y_i) - \sum_0^i x_i* \sum_0^i y_i}
+ {n*\sum_0^i x_i^2 - (\sum_0^i x_i)^2}
+\f]
-b0 = sum(yi)/n - b1*(sum(xi)/n)
+\f[
+ b_0 = \frac{\sum_0^i y_i}{n} - b_1 * \frac{\sum_0^i x_i}{n}
+\f]
*/
-
void least_squares(double *x, double *y, int n, double *m, double *b);
-/* incrimentally update existing values with a new data point */
+
+/**
+ * Incrimentally update existing values with a new data point.
+ */
void least_squares_update(double x, double y, double *m, double *b);
-/*
- return the least squares error:
+/**
+ @return the least squares error:.
+\f[
- (y[i] - y_hat[i])^2
- -------------------
- n
+ \frac{(y_i - \hat{y}_i)^2}{n}
+\f]
*/
double least_squares_error(double *x, double *y, int n, double m, double b);
-/*
- return the maximum least squares error:
+/**
+ @return the maximum least squares error.
- (y[i] - y_hat[i])^2
+\f[
+ (y_i - \hat{y}_i)^2
+\f]
*/
double least_squares_max_error(double *x, double *y, int n, double m, double b);
-// point3d.hxx -- a 3d point class.
-//
-// Adapted from algebra3 by Jean-Francois Doue, started October 1998.
-//
+/**
+ * \file point3d.hxx
+ * A 3d point class (depricated). This class is depricated and we are
+ * in the process of removing all usage of it in favor of plib's "sg"
+ * library of point, vector, and math routines. Plib's sg lib is less
+ * object oriented, but integrates more seamlessly with opengl.
+ *
+ * Adapted from algebra3 by Jean-Francois Doue, started October 1998.
+ */
+
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
//
// This library is free software; you can redistribute it and/or
bool operator== (const Point3D& a, const Point3D& b); // p1 == p2?
-///////////////////////////
-//
-// 3D Point
-//
-///////////////////////////
+/**
+ * 3D Point class.
+ */
class Point3D {
public:
- // Constructors
-
+ /** Default constructor */
Point3D();
Point3D(const double x, const double y, const double z);
explicit Point3D(const double d);
-// polar.hxx -- routines to deal with polar math and transformations
-//
+/**
+ * \file polar3d.hxx
+ * Routines to deal with polar math and transformations.
+ */
+
// Written by Curtis Olson, started June 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// $Id$
-#ifndef _POLAR_HXX
-#define _POLAR_HXX
+#ifndef _POLAR3D_HXX
+#define _POLAR3D_HXX
#ifndef __cplusplus
#include <simgear/math/point3d.hxx>
-// Find the Altitude above the Ellipsoid (WGS84) given the Earth
-// Centered Cartesian coordinate vector Distances are specified in
-// meters.
+/**
+ * Find the Altitude above the Ellipsoid (WGS84) given the Earth
+ * Centered Cartesian coordinate vector Distances are specified in
+ * meters.
+ * @param cp point specified in cartesian coordinates
+ * @return altitude above the (wgs84) earth in meters
+ */
double sgGeodAltFromCart(const Point3D& cp);
-// Convert a polar coordinate to a cartesian coordinate. Lon and Lat
-// must be specified in radians. The SG convention is for distances
-// to be specified in meters
+/**
+ * Convert a polar coordinate to a cartesian coordinate. Lon and Lat
+ * must be specified in radians. The SG convention is for distances
+ * to be specified in meters
+ * @param p point specified in polar coordinates
+ * @return the same point in cartesian coordinates
+ */
inline Point3D sgPolarToCart3d(const Point3D& p) {
double tmp = cos( p.lat() ) * p.radius();
}
-// Convert a cartesian coordinate to polar coordinates (lon/lat
-// specified in radians. Distances are specified in meters.
+/**
+ * Convert a cartesian coordinate to polar coordinates (lon/lat
+ * specified in radians. Distances are specified in meters.
+ * @param cp point specified in cartesian coordinates
+ * @return the same point in polar coordinates
+ */
inline Point3D sgCartToPolar3d(const Point3D& cp) {
return Point3D( atan2( cp.y(), cp.x() ),
SGD_PI_2 -
}
-// calc new lon/lat given starting lon/lat, and offset radial, and
-// distance. NOTE: starting point is specifed in radians, distance is
-// specified in meters (and converted internally to radians)
-// ... assumes a spherical world
+/**
+ * Calculate new lon/lat given starting lon/lat, and offset radial, and
+ * distance. NOTE: starting point is specifed in radians, distance is
+ * specified in meters (and converted internally to radians)
+ * ... assumes a spherical world.
+ * @param orig specified in polar coordinates
+ * @param course offset radial
+ * @param dist offset distance
+ * @return destination point in polar coordinates
+ */
inline Point3D calc_gc_lon_lat( const Point3D& orig, double course,
double dist ) {
Point3D result;
}
-// calc course/dist
+/**
+ * Calculate course/dist given two spherical points.
+ * @param start starting point
+ * @param dest ending point
+ * @param course resulting course
+ * @param dist resulting distance
+ */
inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest,
double *course, double *dist ) {
// d = 2*asin(sqrt((sin((lat1-lat2)/2))^2 +
*dist = d * SG_RAD_TO_NM * SG_NM_TO_METER;
}
-#endif // _POLAR_HXX
+#endif // _POLAR3D_HXX
-// sg_geodesy.hxx -- routines to convert between geodetic and geocentric
-// coordinate systems.
-//
-// Copied and adapted directly from LaRCsim/ls_geodesy.c
-//
+/**
+ * \file sg_geodesy.hxx
+ * Routines to convert between geodetic and geocentric coordinate systems.
+ * Copied and adapted directly from LaRCsim/ls_geodesy.c
+ */
+
// See below for the complete original LaRCsim comments.
//
// $Id$
#include <simgear/math/polar3d.hxx>
-// sgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
-// INPUTS:
-// lat_geoc Geocentric latitude, radians, + = North
-// radius C.G. radius to earth center (meters)
-//
-// OUTPUTS:
-// lat_geod Geodetic latitude, radians, + = North
-// alt C.G. altitude above mean sea level (meters)
-// sea_level_r radius from earth center to sea level at
-// local vertical (surface normal) of C.G. (meters)
-
+/**
+ * Convert from geocentric coordinates to geodetic coordinates
+ * @param lat_geoc (in) Geocentric latitude, radians, + = North
+ * @param radius (in) C.G. radius to earth center (meters)
+ * @param lat_geod (out) Geodetic latitude, radians, + = North
+ * @param alt (out) C.G. altitude above mean sea level (meters)
+ * @param sea_level_r (out) radius from earth center to sea level at
+ * local vertical (surface normal) of C.G. (meters)
+ */
void sgGeocToGeod( double lat_geoc, double radius, double
*lat_geod, double *alt, double *sea_level_r );
-// sgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
-// INPUTS:
-// lat_geod Geodetic latitude, radians, + = North
-// alt C.G. altitude above mean sea level (meters)
-//
-// OUTPUTS:
-// sl_radius SEA LEVEL radius to earth center (meters)
-// (add Altitude to get true distance from earth center.
-// lat_geoc Geocentric latitude, radians, + = North
-//
-
+/**
+ * Convert from geodetic coordinates to geocentric coordinates
+ * @param lat_geod (in) Geodetic latitude, radians, + = North
+ * @param alt (in) C.G. altitude above mean sea level (meters)
+ * @param sl_radius (out) SEA LEVEL radius to earth center (meters)
+ * (add Altitude to get true distance from earth center.
+ * @param lat_geoc (out) Geocentric latitude, radians, + = North
+ */
void sgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
double *lat_geoc );
-// convert a geodetic point lon(radians), lat(radians), elev(meter) to
-// a cartesian point
-
+/**
+ * Convert a geodetic point lon(radians), lat(radians), elev(meter) to
+ * a cartesian point.
+ * @param geodetic point
+ * @return cartesian point
+ */
inline Point3D sgGeodToCart(const Point3D& geod) {
double gc_lon, gc_lat, sl_radius;
}
-// given, alt, lat1, lon1, az1 and distance (s), calculate lat2, lon2
-// and az2. Lat, lon, and azimuth are in degrees. distance in meters
+/**
+ * Given a starting position and an offset radial and distance,
+ * calculate an ending positon on a wgs84 ellipsoid.
+ * @param alt (in) meters
+ * @param lat1 (in) degrees
+ * @param lon1 (in) degrees
+ * @param az1 (in) degrees
+ * @param s (in) distance in meters
+ * @param lat2 (out) degrees
+ * @param lon2 (out) degrees
+ * @param az2 (out) return course in degrees
+ */
int geo_direct_wgs_84 ( double alt, double lat1, double lon1, double az1,
double s, double *lat2, double *lon2, double *az2 );
--- /dev/null
+/**
+ * \file sg_memory.h
+ * memcpy/bcopy portability declarations (not actually used by anything
+ * as best as I can tell.
+ */
+
+// 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_MEMORY_H
+#define _SG_MEMORY_H
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_MEMCPY
+
+# ifdef HAVE_MEMORY_H
+# include <memory.h>
+# endif
+
+# define sgmemcmp memcmp
+# define sgmemcpy memcpy
+# define sgmemzero(dest,len) memset(dest,0,len)
+
+#elif defined(HAVE_BCOPY)
+
+# define sgmemcmp bcmp
+# define sgmemcpy(dest,src,n) bcopy(src,dest,n)
+# define sgmemzero bzero
+
+#else
+
+/*
+ * Neither memcpy() or bcopy() available.
+ * Use substitutes provided be zlib.
+ */
+
+# include <zutil.h>
+# define sgmemcmp zmemcmp
+# define sgmemcpy zmemcpy
+# define sgmemzero zmemzero
+
+#endif
+
+#endif // _SG_MEMORY_H
+
+
#ifdef __SUNPRO_CC
extern "C" {
- long int random(void);
+ long int random();
void srandom(unsigned int seed);
}
#endif
// Seed the random number generater with time() so we don't see the
// same sequence every time
-void sg_srandom_time(void) {
+void sg_srandom_time() {
#ifdef HAVE_RAND
srand(time(NULL));
#else
// return a random number between [0.0, 1.0)
-double sg_random(void) {
+double sg_random() {
#ifdef HAVE_RAND
return(rand() / (double)RAND_MAX);
#else
-// sg_random.h -- routines to handle random number generation
-//
+/**
+ * \file sg_random.h
+ * Routines to handle random number generation and hide platform differences.
+ */
+
// Written by Curtis Olson, started July 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
#endif
-// Seed the random number generater with time() so we don't see the
-// same sequence every time
-void sg_srandom_time(void);
+/**
+ * Seed the random number generater with time() so we don't see the
+ * same sequence every time.
+ */
+void sg_srandom_time();
-// Seed the random number generater with your own seed so can set up
-// repeatable randomization.
+/**
+ * Seed the random number generater with your own seed so can set up
+ * repeatable randomization.
+ * @param seed random number generator seed
+ */
void sg_srandom( unsigned int seed );
-// return a random number between [0.0, 1.0)
-double sg_random(void);
+/**
+ * Return a random number between [0.0, 1.0)
+ * @return next "random" number in the "random" sequence
+ */
+double sg_random();
#ifdef __cplusplus
-// fg_types.hxx -- commonly used types I don't want to have to keep redefining
-//
+/**
+ * \file sg_types.hxx
+ * Commonly used types I don't want to have to keep redefining.
+ */
+
// Written by Curtis Olson, started March 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// $Id$
-#ifndef _FG_TYPES_HXX
-#define _FG_TYPES_HXX
+#ifndef _SG_TYPES_HXX
+#define _SG_TYPES_HXX
#ifndef __cplusplus
SG_USING_STD(vector);
SG_USING_STD(string);
-
+/** STL vector list of ints */
typedef vector < int > int_list;
typedef int_list::iterator int_list_iterator;
typedef int_list::const_iterator const_int_list_iterator;
+/** STL vector list of Point3D */
typedef vector < Point3D > point_list;
typedef point_list::iterator point_list_iterator;
typedef point_list::const_iterator const_point_list_iterator;
+/** STL vector list of strings */
typedef vector < string > string_list;
typedef string_list::iterator string_list_iterator;
typedef string_list::const_iterator const_string_list_iterator;
+/**
+ * Simple 2d point class where members can be accessed as x, dist, or lon
+ * and y, theta, or lat
+ */
class point2d {
public:
union {
};
-#endif // _FG_TYPES_HXX
+#endif // _SG_TYPES_HXX
-// vector.hxx -- additional vector routines
-//
+/**
+ * \file vector.hxx
+ * Additional vector routines.
+ */
+
// Written by Curtis Olson, started December 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
#include <plib/sg.h>
+/**
+ * Map a vector onto a plane.
+ * @param normal (in) normal vector for the plane
+ * @param v0 (in) a point on the plane
+ * @param vec (in) the vector to map onto the plane
+ * @param result (out) the result vector
+ */
inline void sgmap_vec_onto_cur_surface_plane( sgVec3 normal,
sgVec3 v0,
sgVec3 vec,
}
+/**
+ * Copy and negate a vector.
+ * @param dst (out) result vector
+ * @param src (in) input vector
+ */
inline void sgCopyNegateVec4( sgVec4 dst, sgVec4 src )
{
dst [ 0 ] = -src [ 0 ] ;
dst [ 3 ] = -src [ 3 ] ;
}
-// Given a point p, and a line through p0 with direction vector d,
-// find the closest point (p1) on the line
+/**
+ * Given a point p, and a line through p0 with direction vector d,
+ * find the closest point (p1) on the line (float version).
+ * @param p1 (out) closest point to p on the line
+ * @param p (in) original point
+ * @param p0 (in) point on the line
+ * @param d (in) vector defining line direction
+ */
void sgClosestPointToLine( sgVec3 p1, const sgVec3 p, const sgVec3 p0,
const sgVec3 d );
-// Given a point p, and a line through p0 with direction vector d,
-// find the closest point (p1) on the line
+/**
+ * Given a point p, and a line through p0 with direction vector d,
+ * find the closest point (p1) on the line (double version).
+ * @param p1 (out) closest point to p on the line
+ * @param p (in) original point
+ * @param p0 (in) point on the line
+ * @param d (in) vector defining line direction
+ */
void sgdClosestPointToLine( sgdVec3 p1, const sgdVec3 p, const sgdVec3 p0,
const sgdVec3 d );
-// Given a point p, and a line through p0 with direction vector d,
-// find the shortest distance (squared) from the point to the line
+/**
+ * Given a point p, and a line through p0 with direction vector d,
+ * find the shortest distance (squared) from the point to the line (float
+ * version.)
+ * @param p (in) original point
+ * @param p0 (in) point on the line
+ * @param d (in) vector defining line direction
+ * @return shortest distance (squared) from p to line
+ */
double sgClosestPointToLineDistSquared( const sgVec3 p, const sgVec3 p0,
const sgVec3 d );
-// Given a point p, and a line through p0 with direction vector d,
-// find the shortest distance (squared) from the point to the line
+/**
+ * Given a point p, and a line through p0 with direction vector d,
+ * find the shortest distance (squared) from the point to the line (double
+ * version.)
+ * @param p (in) original point
+ * @param p0 (in) point on the line
+ * @param d (in) vector defining line direction
+ * @return shortest distance (squared) from p to line
+ */
double sgdClosestPointToLineDistSquared( const sgdVec3 p, const sgdVec3 p0,
const sgdVec3 d );
-// This is same as
-// sgMakeMatTrans4( sgMat4 sgTrans, sgVec3 trans )
-// sgPostMultMat4( sgMat, sgTRANS );
+/**
+ * This is same as:
+ *
+ * <li> sgMakeMatTrans4( sgMat4 sgTrans, sgVec3 trans )
+ * <li> sgPostMultMat4( sgMat4 src, sgTRANS );
+ *
+ * @param src starting sgMat4 matrix
+ * @param trans translation vector
+ */
void sgPostMultMat4ByTransMat4( sgMat4 src, const sgVec3 trans );
+
#endif // _VECTOR_HXX