C++-ified the comments.
This commit is contained in:
parent
8470a9eda6
commit
c7c353df05
2 changed files with 156 additions and 155 deletions
151
Math/polar3d.cxx
151
Math/polar3d.cxx
|
@ -1,27 +1,25 @@
|
||||||
/**************************************************************************
|
// polar.cxx -- routines to deal with polar math and transformations
|
||||||
* polar.cxx -- routines to deal with polar math and transformations
|
//
|
||||||
*
|
// Written by Curtis Olson, started June 1997.
|
||||||
* Written by Curtis Olson, started June 1997.
|
//
|
||||||
*
|
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||||
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
//
|
||||||
*
|
// This program is free software; you can redistribute it and/or
|
||||||
* This program is free software; you can redistribute it and/or
|
// modify it under the terms of the GNU General Public License as
|
||||||
* modify it under the terms of the GNU General Public License as
|
// published by the Free Software Foundation; either version 2 of the
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
// License, or (at your option) any later version.
|
||||||
* License, or (at your option) any later version.
|
//
|
||||||
*
|
// This program is distributed in the hope that it will be useful, but
|
||||||
* This program is distributed in the hope that it will be useful, but
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// General Public License for more details.
|
||||||
* General Public License for more details.
|
//
|
||||||
*
|
// You should have received a copy of the GNU General Public License
|
||||||
* You should have received a copy of the GNU General Public License
|
// along with this program; if not, write to the Free Software
|
||||||
* along with this program; if not, write to the Free Software
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
//
|
||||||
*
|
// $Id$
|
||||||
* $Id$
|
// (Log is kept at end of this file)
|
||||||
* (Log is kept at end of this file)
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -32,9 +30,9 @@
|
||||||
#include "polar3d.hxx"
|
#include "polar3d.hxx"
|
||||||
|
|
||||||
|
|
||||||
/* 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 FG convention is for distances
|
||||||
* to be specified in meters */
|
// to be specified in meters
|
||||||
Point3D fgPolarToCart3d(const Point3D& p) {
|
Point3D fgPolarToCart3d(const Point3D& p) {
|
||||||
Point3D pnew;
|
Point3D pnew;
|
||||||
double tmp;
|
double tmp;
|
||||||
|
@ -49,8 +47,8 @@ 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.
|
||||||
Point3D fgCartToPolar3d(const Point3D& cp) {
|
Point3D fgCartToPolar3d(const Point3D& cp) {
|
||||||
Point3D pp;
|
Point3D pp;
|
||||||
|
|
||||||
|
@ -58,16 +56,16 @@ Point3D fgCartToPolar3d(const Point3D& cp) {
|
||||||
FG_PI_2 - atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() ),
|
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()) );
|
sqrt(cp.x()*cp.x() + cp.y()*cp.y() + cp.z()*cp.z()) );
|
||||||
|
|
||||||
/* printf("lon = %.2f lat = %.2f radius = %.2f\n",
|
// printf("lon = %.2f lat = %.2f radius = %.2f\n",
|
||||||
pp.lon, pp.lat, pp.radius); */
|
// pp.lon, pp.lat, pp.radius);
|
||||||
|
|
||||||
return(pp);
|
return(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 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 fgGeodAltFromCart(const Point3D& cp)
|
||||||
{
|
{
|
||||||
double t_lat, x_alpha, mu_alpha;
|
double t_lat, x_alpha, mu_alpha;
|
||||||
|
@ -77,8 +75,8 @@ double fgGeodAltFromCart(const Point3D& cp)
|
||||||
lat_geoc = FG_PI_2 - atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() );
|
lat_geoc = FG_PI_2 - atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() );
|
||||||
radius = sqrt( cp.x()*cp.x() + cp.y()*cp.y() + cp.z()*cp.z() );
|
radius = sqrt( cp.x()*cp.x() + cp.y()*cp.y() + cp.z()*cp.z() );
|
||||||
|
|
||||||
if( ( (FG_PI_2 - lat_geoc) < ONE_SECOND ) /* near North pole */
|
if( ( (FG_PI_2 - lat_geoc) < ONE_SECOND ) // near North pole
|
||||||
|| ( (FG_PI_2 + lat_geoc) < ONE_SECOND ) ) /* near South pole */
|
|| ( (FG_PI_2 + lat_geoc) < ONE_SECOND ) ) // near South pole
|
||||||
{
|
{
|
||||||
result = radius - EQUATORIAL_RADIUS_M*E;
|
result = radius - EQUATORIAL_RADIUS_M*E;
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,42 +93,45 @@ double fgGeodAltFromCart(const Point3D& cp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
// $Log$
|
||||||
/* Revision 1.3 1998/10/16 00:50:29 curt
|
// Revision 1.4 1998/10/16 19:30:09 curt
|
||||||
/* Added point3d.hxx to replace cheezy fgPoint3d struct.
|
// C++-ified the comments.
|
||||||
/*
|
//
|
||||||
* Revision 1.2 1998/08/24 20:04:11 curt
|
// Revision 1.3 1998/10/16 00:50:29 curt
|
||||||
* Various "inline" code optimizations contributed by Norman Vine.
|
// Added point3d.hxx to replace cheezy fgPoint3d struct.
|
||||||
*
|
//
|
||||||
* Revision 1.1 1998/07/08 14:40:08 curt
|
// Revision 1.2 1998/08/24 20:04:11 curt
|
||||||
* polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
|
// Various "inline" code optimizations contributed by Norman Vine.
|
||||||
* Updated fg_geodesy comments to reflect that routines expect and produce
|
//
|
||||||
* meters.
|
// Revision 1.1 1998/07/08 14:40:08 curt
|
||||||
*
|
// polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
|
||||||
* Revision 1.2 1998/05/03 00:45:49 curt
|
// Updated fg_geodesy comments to reflect that routines expect and produce
|
||||||
* Commented out a debugging printf.
|
// meters.
|
||||||
*
|
//
|
||||||
* Revision 1.1 1998/05/02 01:50:11 curt
|
// Revision 1.2 1998/05/03 00:45:49 curt
|
||||||
* polar.[ch] renamed to polar3d.[ch]
|
// Commented out a debugging printf.
|
||||||
*
|
//
|
||||||
* Revision 1.6 1998/04/25 22:06:23 curt
|
// Revision 1.1 1998/05/02 01:50:11 curt
|
||||||
* Edited cvs log messages in source files ... bad bad bad!
|
// polar.[ch] renamed to polar3d.[ch]
|
||||||
*
|
//
|
||||||
* Revision 1.5 1998/01/27 00:48:00 curt
|
// Revision 1.6 1998/04/25 22:06:23 curt
|
||||||
* Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
// Edited cvs log messages in source files ... bad bad bad!
|
||||||
* system and commandline/config file processing code.
|
//
|
||||||
*
|
// Revision 1.5 1998/01/27 00:48:00 curt
|
||||||
* Revision 1.4 1998/01/19 19:27:12 curt
|
// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
||||||
* Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
// system and commandline/config file processing code.
|
||||||
* This should simplify things tremendously.
|
//
|
||||||
*
|
// Revision 1.4 1998/01/19 19:27:12 curt
|
||||||
* Revision 1.3 1997/12/15 23:54:54 curt
|
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||||
* Add xgl wrappers for debugging.
|
// This should simplify things tremendously.
|
||||||
* Generate terrain normals on the fly.
|
//
|
||||||
*
|
// Revision 1.3 1997/12/15 23:54:54 curt
|
||||||
* Revision 1.2 1997/07/31 22:52:27 curt
|
// Add xgl wrappers for debugging.
|
||||||
* Working on redoing internal coordinate systems & scenery transformations.
|
// Generate terrain normals on the fly.
|
||||||
*
|
//
|
||||||
* Revision 1.1 1997/07/07 21:02:36 curt
|
// Revision 1.2 1997/07/31 22:52:27 curt
|
||||||
* Initial revision.
|
// Working on redoing internal coordinate systems & scenery transformations.
|
||||||
* */
|
//
|
||||||
|
// Revision 1.1 1997/07/07 21:02:36 curt
|
||||||
|
// Initial revision.
|
||||||
|
|
||||||
|
|
160
Math/polar3d.hxx
160
Math/polar3d.hxx
|
@ -1,27 +1,25 @@
|
||||||
/**************************************************************************
|
// polar.hxx -- routines to deal with polar math and transformations
|
||||||
* polar.hxx -- routines to deal with polar math and transformations
|
//
|
||||||
*
|
// Written by Curtis Olson, started June 1997.
|
||||||
* Written by Curtis Olson, started June 1997.
|
//
|
||||||
*
|
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
||||||
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
|
//
|
||||||
*
|
// This program is free software; you can redistribute it and/or
|
||||||
* This program is free software; you can redistribute it and/or
|
// modify it under the terms of the GNU General Public License as
|
||||||
* modify it under the terms of the GNU General Public License as
|
// published by the Free Software Foundation; either version 2 of the
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
// License, or (at your option) any later version.
|
||||||
* License, or (at your option) any later version.
|
//
|
||||||
*
|
// This program is distributed in the hope that it will be useful, but
|
||||||
* This program is distributed in the hope that it will be useful, but
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// General Public License for more details.
|
||||||
* General Public License for more details.
|
//
|
||||||
*
|
// You should have received a copy of the GNU General Public License
|
||||||
* You should have received a copy of the GNU General Public License
|
// along with this program; if not, write to the Free Software
|
||||||
* along with this program; if not, write to the Free Software
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
//
|
||||||
*
|
// $Id$
|
||||||
* $Id$
|
// (Log is kept at end of this file)
|
||||||
* (Log is kept at end of this file)
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _POLAR_HXX
|
#ifndef _POLAR_HXX
|
||||||
|
@ -34,73 +32,75 @@
|
||||||
|
|
||||||
|
|
||||||
#include <Include/fg_constants.h>
|
#include <Include/fg_constants.h>
|
||||||
// #include <Include/fg_types.h>
|
|
||||||
#include <Math/point3d.hxx>
|
#include <Math/point3d.hxx>
|
||||||
|
|
||||||
|
|
||||||
/* 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 FG convention is for distances
|
||||||
* to be specified in meters */
|
// to be specified in meters
|
||||||
Point3D fgPolarToCart3d(const Point3D& p);
|
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.
|
||||||
Point3D fgCartToPolar3d(const Point3D& cp);
|
Point3D fgCartToPolar3d(const Point3D& cp);
|
||||||
|
|
||||||
|
|
||||||
/* 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 fgGeodAltFromCart(const Point3D& cp);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _POLAR_HXX */
|
#endif // _POLAR_HXX
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
// $Log$
|
||||||
/* Revision 1.3 1998/10/16 00:50:30 curt
|
// Revision 1.4 1998/10/16 19:30:07 curt
|
||||||
/* Added point3d.hxx to replace cheezy fgPoint3d struct.
|
// C++-ified the comments.
|
||||||
/*
|
//
|
||||||
* Revision 1.2 1998/08/24 20:04:12 curt
|
// Revision 1.3 1998/10/16 00:50:30 curt
|
||||||
* Various "inline" code optimizations contributed by Norman Vine.
|
// Added point3d.hxx to replace cheezy fgPoint3d struct.
|
||||||
*
|
//
|
||||||
* Revision 1.1 1998/07/08 14:40:09 curt
|
// Revision 1.2 1998/08/24 20:04:12 curt
|
||||||
* polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
|
// Various "inline" code optimizations contributed by Norman Vine.
|
||||||
* Updated fg_geodesy comments to reflect that routines expect and produce
|
//
|
||||||
* meters.
|
// Revision 1.1 1998/07/08 14:40:09 curt
|
||||||
*
|
// polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
|
||||||
* Revision 1.1 1998/05/02 01:50:11 curt
|
// Updated fg_geodesy comments to reflect that routines expect and produce
|
||||||
* polar.[ch] renamed to polar3d.[ch]
|
// meters.
|
||||||
*
|
//
|
||||||
* Revision 1.9 1998/04/25 22:06:23 curt
|
// Revision 1.1 1998/05/02 01:50:11 curt
|
||||||
* Edited cvs log messages in source files ... bad bad bad!
|
// polar.[ch] renamed to polar3d.[ch]
|
||||||
*
|
//
|
||||||
* Revision 1.8 1998/04/21 17:03:50 curt
|
// Revision 1.9 1998/04/25 22:06:23 curt
|
||||||
* Prepairing for C++ integration.
|
// Edited cvs log messages in source files ... bad bad bad!
|
||||||
*
|
//
|
||||||
* Revision 1.7 1998/01/27 00:48:00 curt
|
// Revision 1.8 1998/04/21 17:03:50 curt
|
||||||
* Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
// Prepairing for C++ integration.
|
||||||
* system and commandline/config file processing code.
|
//
|
||||||
*
|
// Revision 1.7 1998/01/27 00:48:00 curt
|
||||||
* Revision 1.6 1998/01/22 02:59:39 curt
|
// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
||||||
* Changed #ifdef FILE_H to #ifdef _FILE_H
|
// system and commandline/config file processing code.
|
||||||
*
|
//
|
||||||
* Revision 1.5 1998/01/19 19:27:13 curt
|
// Revision 1.6 1998/01/22 02:59:39 curt
|
||||||
* Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
// Changed #ifdef FILE_H to #ifdef _FILE_H
|
||||||
* This should simplify things tremendously.
|
//
|
||||||
*
|
// Revision 1.5 1998/01/19 19:27:13 curt
|
||||||
* Revision 1.4 1997/12/15 23:54:55 curt
|
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
||||||
* Add xgl wrappers for debugging.
|
// This should simplify things tremendously.
|
||||||
* Generate terrain normals on the fly.
|
//
|
||||||
*
|
// Revision 1.4 1997/12/15 23:54:55 curt
|
||||||
* Revision 1.3 1997/07/31 22:52:28 curt
|
// Add xgl wrappers for debugging.
|
||||||
* Working on redoing internal coordinate systems & scenery transformations.
|
// Generate terrain normals on the fly.
|
||||||
*
|
//
|
||||||
* Revision 1.2 1997/07/23 21:52:21 curt
|
// Revision 1.3 1997/07/31 22:52:28 curt
|
||||||
* Put comments around the text after an #endif for increased portability.
|
// Working on redoing internal coordinate systems & scenery transformations.
|
||||||
*
|
//
|
||||||
* Revision 1.1 1997/07/07 21:02:37 curt
|
// Revision 1.2 1997/07/23 21:52:21 curt
|
||||||
* Initial revision.
|
// Put comments around the text after an #endif for increased portability.
|
||||||
*
|
//
|
||||||
*/
|
// Revision 1.1 1997/07/07 21:02:37 curt
|
||||||
|
// Initial revision.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue