Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GeographicLib::LocalCartesian Class Reference

Local cartesian coordinates. More...

#include <LocalCartesian.hpp>

Public Member Functions

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
 
 LocalCartesian (const Geocentric &earth=Geocentric::WGS84())
 
 LocalCartesian (real lat0, real lon0, real h0=0, const Geocentric &earth=Geocentric::WGS84())
 
void Reset (real lat0, real lon0, real h0=0)
 
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
Math::real LatitudeOrigin () const
 
Math::real LongitudeOrigin () const
 
Math::real HeightOrigin () const
 
Math::real MajorRadius () const
 
Math::real Flattening () const
 

Private Types

typedef Math::real real
 

Private Member Functions

void IntForward (real lat, real lon, real h, real &x, real &y, real &z, real M[dim2_]) const
 
void IntReverse (real x, real y, real z, real &lat, real &lon, real &h, real M[dim2_]) const
 
void MatrixMultiply (real M[dim2_]) const
 

Private Attributes

Geocentric _earth
 
real _h0
 
real _lat0
 
real _lon0
 
real _r [dim2_]
 
real _x0
 
real _y0
 
real _z0
 

Static Private Attributes

static const size_t dim2_ = dim_ * dim_
 
static const size_t dim_ = 3
 

Detailed Description

Local cartesian coordinates.

Convert between geodetic coordinates latitude = lat, longitude = lon, height = h (measured vertically from the surface of the ellipsoid) to local cartesian coordinates (x, y, z). The origin of local cartesian coordinate system is at lat = lat0, lon = lon0, h = h0. The z axis is normal to the ellipsoid; the y axis points due north. The plane z = - h0 is tangent to the ellipsoid.

The conversions all take place via geocentric coordinates using a Geocentric object (by default Geocentric::WGS84()).

Example of use:

// Example of using the GeographicLib::LocalCartesian class
#include <iostream>
#include <exception>
#include <cmath>
using namespace std;
using namespace GeographicLib;
int main() {
try {
// Alternatively: const Geocentric& earth = Geocentric::WGS84();
const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris
LocalCartesian proj(lat0, lon0, 0, earth);
{
// Sample forward calculation
double lat = 50.9, lon = 1.8, h = 0; // Calais
double x, y, z;
proj.Forward(lat, lon, h, x, y, z);
cout << x << " " << y << " " << z << "\n";
}
{
// Sample reverse calculation
double x = -38e3, y = 230e3, z = -4e3;
double lat, lon, h;
proj.Reverse(x, y, z, lat, lon, h);
cout << lat << " " << lon << " " << h << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}

CartConvert is a command-line utility providing access to the functionality of Geocentric and LocalCartesian.

Definition at line 38 of file LocalCartesian.hpp.

Member Typedef Documentation

◆ real

Definition at line 40 of file LocalCartesian.hpp.

Constructor & Destructor Documentation

◆ LocalCartesian() [1/2]

GeographicLib::LocalCartesian::LocalCartesian ( real  lat0,
real  lon0,
real  h0 = 0,
const Geocentric earth = Geocentric::WGS84() 
)
inline

Constructor setting the origin.

Parameters
[in]lat0latitude at origin (degrees).
[in]lon0longitude at origin (degrees).
[in]h0height above ellipsoid at origin (meters); default 0.
[in]earthGeocentric object for the transformation; default Geocentric::WGS84().

lat0 should be in the range [−90°, 90°].

Definition at line 64 of file LocalCartesian.hpp.

◆ LocalCartesian() [2/2]

GeographicLib::LocalCartesian::LocalCartesian ( const Geocentric earth = Geocentric::WGS84())
inlineexplicit

Default constructor.

Parameters
[in]earthGeocentric object for the transformation; default Geocentric::WGS84().

Sets lat0 = 0, lon0 = 0, h0 = 0.

Definition at line 77 of file LocalCartesian.hpp.

Member Function Documentation

◆ Flattening()

Math::real GeographicLib::LocalCartesian::Flattening ( ) const
inline
Returns
f the flattening of the ellipsoid. This is the value inherited from the Geocentric object used in the constructor.

Definition at line 229 of file LocalCartesian.hpp.

◆ Forward() [1/2]

void GeographicLib::LocalCartesian::Forward ( real  lat,
real  lon,
real  h,
real x,
real y,
real z 
) const
inline

Convert from geodetic to local cartesian coordinates.

Parameters
[in]latlatitude of point (degrees).
[in]lonlongitude of point (degrees).
[in]hheight of point above the ellipsoid (meters).
[out]xlocal cartesian coordinate (meters).
[out]ylocal cartesian coordinate (meters).
[out]zlocal cartesian coordinate (meters).

lat should be in the range [−90°, 90°].

Definition at line 104 of file LocalCartesian.hpp.

◆ Forward() [2/2]

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

Convert from geodetic to local cartesian coordinates and return rotation matrix.

Parameters
[in]latlatitude of point (degrees).
[in]lonlongitude of point (degrees).
[in]hheight of point above the ellipsoid (meters).
[out]xlocal cartesian coordinate (meters).
[out]ylocal cartesian coordinate (meters).
[out]zlocal cartesian coordinate (meters).
[out]Mif the length of the vector is 9, fill with the rotation matrix in row-major order.

lat should be in the range [−90°, 90°].

Let v be a unit vector located at (lat, lon, h). We can express v as column vectors in one of two ways

  • in east, north, up coordinates (where the components are relative to a local coordinate system at (lat, lon, h)); call this representation v1.
  • in x, y, z coordinates (where the components are relative to the local coordinate system at (lat0, lon0, h0)); call this representation v0.

Then we have v0 = Mv1.

Definition at line 135 of file LocalCartesian.hpp.

◆ HeightOrigin()

Math::real GeographicLib::LocalCartesian::HeightOrigin ( ) const
inline
Returns
height of the origin (meters).

Definition at line 216 of file LocalCartesian.hpp.

◆ IntForward()

void GeographicLib::LocalCartesian::IntForward ( real  lat,
real  lon,
real  h,
real x,
real y,
real z,
real  M[dim2_] 
) const
private

Definition at line 37 of file src/LocalCartesian.cpp.

◆ IntReverse()

void GeographicLib::LocalCartesian::IntReverse ( real  x,
real  y,
real  z,
real lat,
real lon,
real h,
real  M[dim2_] 
) const
private

Definition at line 50 of file src/LocalCartesian.cpp.

◆ LatitudeOrigin()

Math::real GeographicLib::LocalCartesian::LatitudeOrigin ( ) const
inline
Returns
latitude of the origin (degrees).

Definition at line 206 of file LocalCartesian.hpp.

◆ LongitudeOrigin()

Math::real GeographicLib::LocalCartesian::LongitudeOrigin ( ) const
inline
Returns
longitude of the origin (degrees).

Definition at line 211 of file LocalCartesian.hpp.

◆ MajorRadius()

Math::real GeographicLib::LocalCartesian::MajorRadius ( ) const
inline
Returns
a the equatorial radius of the ellipsoid (meters). This is the value of a inherited from the Geocentric object used in the constructor.

Definition at line 223 of file LocalCartesian.hpp.

◆ MatrixMultiply()

void GeographicLib::LocalCartesian::MatrixMultiply ( real  M[dim2_]) const
private

Definition at line 27 of file src/LocalCartesian.cpp.

◆ Reset()

void GeographicLib::LocalCartesian::Reset ( real  lat0,
real  lon0,
real  h0 = 0 
)

Reset the origin.

Parameters
[in]lat0latitude at origin (degrees).
[in]lon0longitude at origin (degrees).
[in]h0height above ellipsoid at origin (meters); default 0.

lat0 should be in the range [−90°, 90°].

Definition at line 16 of file src/LocalCartesian.cpp.

◆ Reverse() [1/2]

void GeographicLib::LocalCartesian::Reverse ( real  x,
real  y,
real  z,
real lat,
real lon,
real h 
) const
inline

Convert from local cartesian to geodetic coordinates.

Parameters
[in]xlocal cartesian coordinate (meters).
[in]ylocal cartesian coordinate (meters).
[in]zlocal cartesian coordinate (meters).
[out]latlatitude of point (degrees).
[out]lonlongitude of point (degrees).
[out]hheight of point above the ellipsoid (meters).

The value of lon returned is in the range [−180°, 180°].

Definition at line 159 of file LocalCartesian.hpp.

◆ Reverse() [2/2]

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

Convert from local cartesian to geodetic coordinates and return rotation matrix.

Parameters
[in]xlocal cartesian coordinate (meters).
[in]ylocal cartesian coordinate (meters).
[in]zlocal cartesian coordinate (meters).
[out]latlatitude of point (degrees).
[out]lonlongitude of point (degrees).
[out]hheight of point above the ellipsoid (meters).
[out]Mif 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

  • in east, north, up coordinates (where the components are relative to a local coordinate system at (lat, lon, h)); call this representation v1.
  • in x, y, z coordinates (where the components are relative to the local coordinate system at (lat0, lon0, h0)); call this representation v0.

Then we have v1 = MTv0, where MT is the transpose of M.

Definition at line 189 of file LocalCartesian.hpp.

Member Data Documentation

◆ _earth

Geocentric GeographicLib::LocalCartesian::_earth
private

Definition at line 43 of file LocalCartesian.hpp.

◆ _h0

real GeographicLib::LocalCartesian::_h0
private

Definition at line 44 of file LocalCartesian.hpp.

◆ _lat0

real GeographicLib::LocalCartesian::_lat0
private

Definition at line 44 of file LocalCartesian.hpp.

◆ _lon0

real GeographicLib::LocalCartesian::_lon0
private

Definition at line 44 of file LocalCartesian.hpp.

◆ _r

real GeographicLib::LocalCartesian::_r[dim2_]
private

Definition at line 45 of file LocalCartesian.hpp.

◆ _x0

real GeographicLib::LocalCartesian::_x0
private

Definition at line 45 of file LocalCartesian.hpp.

◆ _y0

real GeographicLib::LocalCartesian::_y0
private

Definition at line 45 of file LocalCartesian.hpp.

◆ _z0

real GeographicLib::LocalCartesian::_z0
private

Definition at line 45 of file LocalCartesian.hpp.

◆ dim2_

const size_t GeographicLib::LocalCartesian::dim2_ = dim_ * dim_
staticprivate

Definition at line 42 of file LocalCartesian.hpp.

◆ dim_

const size_t GeographicLib::LocalCartesian::dim_ = 3
staticprivate

Definition at line 41 of file LocalCartesian.hpp.


The documentation for this class was generated from the following files:
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
h
const double h
Definition: testSimpleHelicopter.cpp:19
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
GeographicLib::Geocentric
Geocentric coordinates
Definition: Geocentric.hpp:67
Geocentric.hpp
Header for GeographicLib::Geocentric class.
example::lat0
const double lat0
Definition: testGPSFactor.cpp:41
example::lon0
const double lon0
Definition: testGPSFactor.cpp:41
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
y
Scalar * y
Definition: level1_cplx_impl.h:124
GeographicLib::Constants::WGS84_a
static T WGS84_a()
Definition: Constants.hpp:159
std
Definition: BFloat16.h:88
LocalCartesian.hpp
Header for GeographicLib::LocalCartesian class.
GeographicLib::LocalCartesian
Local cartesian coordinates.
Definition: LocalCartesian.hpp:38
GeographicLib::Constants::WGS84_f
static T WGS84_f()
Definition: Constants.hpp:169
lon
static const double lon
Definition: testGeographicLib.cpp:34
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:23:28