GeographicLib 2.1.2
|
Geocentric coordinates More...
#include <GeographicLib/Geocentric.hpp>
Public Member Functions | |
Geocentric (real a, real f) | |
Geocentric () | |
void | Forward (real lat, real lon, real h, real &X, real &Y, real &Z) const |
void | Forward (real lat, real lon, real h, real &X, real &Y, real &Z, std::vector< real > &M) const |
void | Reverse (real X, real Y, real Z, real &lat, real &lon, real &h) const |
void | Reverse (real X, real Y, real Z, real &lat, real &lon, real &h, std::vector< real > &M) const |
Inspector functions | |
bool | Init () const |
Math::real | EquatorialRadius () const |
Math::real | Flattening () const |
Static Public Member Functions | |
static const Geocentric & | WGS84 () |
Friends | |
class | LocalCartesian |
class | MagneticCircle |
class | MagneticModel |
class | GravityCircle |
class | GravityModel |
class | NormalGravity |
Geocentric coordinates
Convert between geodetic coordinates latitude = lat, longitude = lon, height = h (measured vertically from the surface of the ellipsoid) to geocentric coordinates (X, Y, Z). The origin of geocentric coordinates is at the center of the earth. The Z axis goes thru the north pole, lat = 90°. The X axis goes thru lat = 0, lon = 0. Geocentric coordinates are also known as earth centered, earth fixed (ECEF) coordinates.
The conversion from geographic to geocentric coordinates is straightforward. For the reverse transformation we use
Several changes have been made to ensure that the method returns accurate results for all finite inputs (even if h is infinite). The changes are described in Appendix B of
Vermeille similarly updated his method in
See Geocentric coordinates for more information.
The errors in these routines are close to round-off. Specifically, for points within 5000 km of the surface of the ellipsoid (either inside or outside the ellipsoid), the error is bounded by 7 nm (7 nanometers) for the WGS84 ellipsoid. See Geocentric coordinates for further information on the errors.
Example of use:
CartConvert is a command-line utility providing access to the functionality of Geocentric and LocalCartesian.
Definition at line 67 of file Geocentric.hpp.
GeographicLib::Geocentric::Geocentric | ( | real | a, |
real | f | ||
) |
Constructor for an ellipsoid with
[in] | a | equatorial radius (meters). |
[in] | f | flattening of ellipsoid. Setting f = 0 gives a sphere. Negative f gives a prolate ellipsoid. |
GeographicErr | if a or (1 − f) a is not positive. |
Definition at line 16 of file Geocentric.cpp.
|
inline |
A default constructor (for use by NormalGravity).
Definition at line 118 of file Geocentric.hpp.
|
inline |
Convert from geodetic to geocentric coordinates.
[in] | lat | latitude of point (degrees). |
[in] | lon | longitude of point (degrees). |
[in] | h | height of point above the ellipsoid (meters). |
[out] | X | geocentric coordinate (meters). |
[out] | Y | geocentric coordinate (meters). |
[out] | Z | geocentric coordinate (meters). |
lat should be in the range [−90°, 90°].
Definition at line 132 of file Geocentric.hpp.
Referenced by main(), and GeographicLib::LocalCartesian::Reset().
|
inline |
Convert from geodetic to geocentric coordinates and return rotation matrix.
[in] | lat | latitude of point (degrees). |
[in] | lon | longitude of point (degrees). |
[in] | h | height of point above the ellipsoid (meters). |
[out] | X | geocentric coordinate (meters). |
[out] | Y | geocentric coordinate (meters). |
[out] | Z | geocentric coordinate (meters). |
[out] | M | if the length of the vector is 9, fill with the rotation matrix in row-major order. |
Let v be a unit vector located at (lat, lon, h). We can express v as column vectors in one of two ways
Then we have v0 = M ⋅ v1.
Definition at line 161 of file Geocentric.hpp.
|
inline |
Convert from geocentric to geodetic to coordinates.
[in] | X | geocentric coordinate (meters). |
[in] | Y | geocentric coordinate (meters). |
[in] | Z | geocentric coordinate (meters). |
[out] | lat | latitude of point (degrees). |
[out] | lon | longitude of point (degrees). |
[out] | h | height of point above the ellipsoid (meters). |
In general, there are multiple solutions and the result which minimizes |h |is returned, i.e., (lat, lon) corresponds to the closest point on the ellipsoid. If there are still multiple solutions with different latitudes (applies only if Z = 0), then the solution with lat > 0 is returned. If there are still multiple solutions with different longitudes (applies only if X = Y = 0) then lon = 0 is returned. The value of h returned satisfies h ≥ − a (1 − e2) / sqrt(1 − e2 sin2lat). The value of lon returned is in the range [−180°, 180°].
Definition at line 195 of file Geocentric.hpp.
Referenced by main().
|
inline |
Convert from geocentric to geodetic to coordinates.
[in] | X | geocentric coordinate (meters). |
[in] | Y | geocentric coordinate (meters). |
[in] | Z | geocentric coordinate (meters). |
[out] | lat | latitude of point (degrees). |
[out] | lon | longitude of point (degrees). |
[out] | h | height of point above the ellipsoid (meters). |
[out] | M | if the length of the vector is 9, fill with the rotation matrix in row-major order. |
Let v be a unit vector located at (lat, lon, h). We can express v as column vectors in one of two ways
Then we have v1 = MT ⋅ v0, where MT is the transpose of M.
Definition at line 224 of file Geocentric.hpp.
|
inline |
Definition at line 243 of file Geocentric.hpp.
|
inline |
Definition at line 248 of file Geocentric.hpp.
References GeographicLib::Math::NaN().
Referenced by GeographicLib::LocalCartesian::EquatorialRadius(), and GeographicLib::MagneticModel::EquatorialRadius().
|
inline |
Definition at line 255 of file Geocentric.hpp.
References GeographicLib::Math::NaN().
Referenced by GeographicLib::LocalCartesian::Flattening(), and GeographicLib::MagneticModel::Flattening().
|
static |
A global instantiation of Geocentric with the parameters for the WGS84 ellipsoid.
Definition at line 31 of file Geocentric.cpp.
References GeographicLib::Constants::WGS84_a(), and GeographicLib::Constants::WGS84_f().
|
friend |
Definition at line 70 of file Geocentric.hpp.
|
friend |
Definition at line 71 of file Geocentric.hpp.
|
friend |
Definition at line 72 of file Geocentric.hpp.
|
friend |
Definition at line 73 of file Geocentric.hpp.
|
friend |
Definition at line 74 of file Geocentric.hpp.
|
friend |
Definition at line 75 of file Geocentric.hpp.