Public Member Functions | Static Public Attributes | Friends

GeographicLib::Geocentric Class Reference

Geocentric coordinates More...

#include <GeographicLib/Geocentric.hpp>

List of all members.

Public Member Functions

 Geocentric (real a, real r)
void Forward (real lat, real lon, real h, real &x, real &y, real &z) const throw ()
void Forward (real lat, real lon, real h, real &x, real &y, real &z, std::vector< real > &M) const throw ()
void Reverse (real x, real y, real z, real &lat, real &lon, real &h) const throw ()
void Reverse (real x, real y, real z, real &lat, real &lon, real &h, std::vector< real > &M) const throw ()
Inspector functions

Math::real MajorRadius () const throw ()
Math::real InverseFlattening () const throw ()

Static Public Attributes

static const Geocentric WGS84

Friends

class LocalCartesian

Detailed Description

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 = 90o. 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

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 for the WGS84 ellipsoid. See Geocentric coordinates for further information on the errors.

Definition at line 55 of file Geocentric.hpp.


Constructor & Destructor Documentation

GeographicLib::Geocentric::Geocentric ( real  a,
real  r 
)

Constructor for a ellipsoid with

Parameters:
[in] a equatorial radius (meters)
[in] r reciprocal flattening. Setting r = 0 implies r = inf or flattening = 0 (i.e., a sphere). Negative r indicates a prolate ellipsoid.

An exception is thrown if either of the axes of the ellipsoid is non-positive.

Definition at line 26 of file Geocentric.cpp.


Member Function Documentation

void GeographicLib::Geocentric::Forward ( real  lat,
real  lon,
real  h,
real &  x,
real &  y,
real &  z 
) const throw () [inline]

Convert from geodetic to geocentric coordinates.

Parameters:
[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]; lon and lon0 should be in the range [-180, 360].

Definition at line 98 of file Geocentric.hpp.

void GeographicLib::Geocentric::Forward ( real  lat,
real  lon,
real  h,
real &  x,
real &  y,
real &  z,
std::vector< real > &  M 
) const throw () [inline]

Convert from geodetic to geocentric coordinates and return rotation matrix.

Parameters:
[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.

Pre-multiplying a unit vector in local cartesian coordinates (east, north, up) by M transforms the vector to geocentric coordinates.

Definition at line 119 of file Geocentric.hpp.

void GeographicLib::Geocentric::Reverse ( real  x,
real  y,
real  z,
real &  lat,
real &  lon,
real &  h 
) const throw () [inline]

Convert from geocentric to geodetic to coordinates.

Parameters:
[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 maximizes h is returned. If there are still multiple solutions with different latitutes (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 147 of file Geocentric.hpp.

void GeographicLib::Geocentric::Reverse ( real  x,
real  y,
real  z,
real &  lat,
real &  lon,
real &  h,
std::vector< real > &  M 
) const throw () [inline]

Convert from geocentric to geodetic to coordinates.

Parameters:
[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.

Pre-multiplying a unit vector in geocentric coordinates by the transpose of M transforms the vector to local cartesian coordinates (east, north, up).

Definition at line 168 of file Geocentric.hpp.

Math::real GeographicLib::Geocentric::MajorRadius (  )  const throw () [inline]
Returns:
a the equatorial radius of the ellipsoid (meters). This is the value used in the constructor.

Definition at line 184 of file Geocentric.hpp.

Referenced by GeographicLib::LocalCartesian::MajorRadius().

Math::real GeographicLib::Geocentric::InverseFlattening (  )  const throw () [inline]
Returns:
r the inverse flattening of the ellipsoid. This is the value used in the constructor. A value of 0 is returned for a sphere (infinite inverse flattening).

Definition at line 191 of file Geocentric.hpp.

Referenced by GeographicLib::LocalCartesian::InverseFlattening().


Friends And Related Function Documentation

friend class LocalCartesian [friend]

Definition at line 58 of file Geocentric.hpp.


Member Data Documentation

A global instantiation of Geocentric with the parameters for the WGS84 ellipsoid.

Definition at line 198 of file Geocentric.hpp.


The documentation for this class was generated from the following files: