3 * Routines to deal with polar math and transformations.
6 // Written by Curtis Olson, started June 1997.
8 // Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Library General Public
12 // License as published by the Free Software Foundation; either
13 // version 2 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Library General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 # error This library requires C++
35 #include <simgear/math/point3d.hxx>
39 * Calculate new lon/lat given starting lon/lat, and offset radial, and
40 * distance. NOTE: starting point is specifed in radians, distance is
41 * specified in meters (and converted internally to radians)
42 * ... assumes a spherical world.
43 * @param orig specified in polar coordinates
44 * @param course offset radial
45 * @param dist offset distance
46 * @return destination point in polar coordinates
48 inline Point3D calc_gc_lon_lat(const Point3D& orig, double course, double dist)
49 { return Point3D::fromSGGeoc(orig.toSGGeoc().advanceRadM(course, dist)); }
53 * Calculate course/dist given two spherical points.
54 * @param start starting point
55 * @param dest ending point
56 * @param course resulting course
57 * @param dist resulting distance
59 inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest,
60 double *course, double *dist )
62 SGGeoc gs = start.toSGGeoc();
63 SGGeoc gd = dest.toSGGeoc();
64 *course = SGGeoc::courseRad(gs, gd);
65 *dist = SGGeoc::distanceM(gs, gd);
68 #endif // _POLAR3D_HXX