LocalCartesian.hpp

Go to the documentation of this file.
00001 /**
00002  * \file LocalCartesian.hpp
00003  * \brief Header for GeographicLib::LocalCartesian class
00004  *
00005  * Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com>
00006  * and licensed under the LGPL.  For more information, see
00007  * http://geographiclib.sourceforge.net/
00008  **********************************************************************/
00009 
00010 #if !defined(GEOGRAPHICLIB_LOCALCARTESIAN_HPP)
00011 #define GEOGRAPHICLIB_LOCALCARTESIAN_HPP "$Id: LocalCartesian.hpp 6785 2010-01-05 22:15:42Z karney $"
00012 
00013 #include "GeographicLib/Geocentric.hpp"
00014 #include "GeographicLib/Constants.hpp"
00015 
00016 namespace GeographicLib {
00017 
00018   /**
00019    * \brief Local Cartesian coordinates
00020    *
00021    * Convert between geodetic coordinates latitude = \e lat, longitude = \e
00022    * lon, height = \e h (measured vertically from the surface of the ellipsoid)
00023    * to local cartesian coordinates (\e x, \e y, \e z).  The origin of local
00024    * cartesian coordinate system is at \e lat = \e lat0, \e lon = \e lon0, \e h
00025    * = \e h0. The \e z axis is normal to the ellipsoid; the \e y axis points
00026    * due north.  The plane \e z = - \e h0 is tangent to the ellipsoid.
00027    *
00028    * The conversions all take place via geocentric coordinates using a
00029    * GeographicLib::Geocentric object (by default
00030    * GeographicLib::Geocentric::WGS84).
00031    **********************************************************************/
00032 
00033   class LocalCartesian {
00034   private:
00035     typedef Math::real real;
00036     const Geocentric _earth;
00037     real _lat0, _lon0, _h0;
00038     real _x0, _y0, _z0,
00039       _rxx, _rxy, _rxz,
00040       _ryx, _ryy, _ryz,
00041       _rzx, _rzy, _rzz;
00042   public:
00043 
00044     /**
00045      * Constructor setting the origin to latitude = \e lat0, longitude = \e
00046      * lon0 (degrees), height = \e h0 (meters).  The optional \e earth argument
00047      * (default Geocentric::WGS84) specifies the Geocentric object to use for
00048      * the transformation.
00049      **********************************************************************/
00050     LocalCartesian(real lat0, real lon0, real h0 = 0,
00051                    const Geocentric& earth = Geocentric::WGS84) throw()
00052       : _earth(earth)
00053     { Reset(lat0, lon0, h0); }
00054 
00055     /**
00056      * Default constructor sets the origin to \e lat0 = 0, \e lon0 = 0, \e h0 =
00057      * 0.  The optional \e earth argument (default Geocentric::WGS84) specifies
00058      * the Geocentric object to use for the transformation.
00059      **********************************************************************/
00060     explicit LocalCartesian(const Geocentric& earth = Geocentric::WGS84)
00061       throw()
00062       : _earth(earth)
00063     { Reset(real(0), real(0), real(0)); }
00064 
00065     /**
00066      * Change the origin to latitude = \e lat0, longitude = \e lon0 (degrees),
00067      * height = \e h0 (meters).
00068      **********************************************************************/
00069     void Reset(real lat0, real lon0, real h0 = 0)
00070       throw();
00071 
00072     /**
00073      * Convert from geodetic coordinates \e lat, \e lon (degrees), \e h
00074      * (meters) to local cartesian coordinates \e x, \e y, \e z (meters).  \e
00075      * lat should be in the range [-90, 90]; \e lon and \e lon0 should be in
00076      * the range [-180, 360].
00077      **********************************************************************/
00078     void Forward(real lat, real lon, real h, real& x, real& y, real& z)
00079       const throw();
00080 
00081     /**
00082      * Convert from local cartesian \e x, \e y, \e z (meters) to geodetic
00083      * coordinates \e lat, \e lon (degrees), \e h (meters).  The value of \e
00084      * lon returned is in the range [-180, 180).
00085      **********************************************************************/
00086     void Reverse(real x, real y, real z, real& lat, real& lon, real& h)
00087       const throw();
00088 
00089     /**
00090      * Return the latitude of the origin (degrees).
00091      **********************************************************************/
00092     Math::real LatitudeOrigin() const throw() { return _lat0; }
00093 
00094     /**
00095      * Return the longitude of the origin (degrees).
00096      **********************************************************************/
00097     Math::real LongitudeOrigin() const throw() { return _lon0; }
00098 
00099     /**
00100      * Return the height of the origin (meters).
00101      **********************************************************************/
00102     Math::real HeightOrigin() const throw() { return _h0; }
00103 
00104     /**
00105      * The major radius of the ellipsoid (meters).  This is that value of \e a
00106      * inherited from the Geocentric object used in the constructor.
00107      **********************************************************************/
00108     Math::real MajorRadius() const throw() { return _earth.MajorRadius(); }
00109 
00110     /**
00111      * The inverse flattening of the ellipsoid.  This is that value of \e r
00112      * inherited from the Geocentric object used in the constructor.  A value
00113      * of 0 is returned for a sphere (infinite inverse flattening).
00114      **********************************************************************/
00115     Math::real InverseFlattening() const throw()
00116     { return _earth.InverseFlattening(); }
00117   };
00118 
00119 } // namespace GeographicLib
00120 
00121 #endif

Generated on 21 May 2010 for GeographicLib by  doxygen 1.6.1