The geo location class. More...

#include "murl_util_geo_location.h"

Public Member Functions

 GeoLocation ()
 The default constructor.
 
 GeoLocation (Double latitude, Double longitude, Double altitude)
 The constructor taking separate location values. More...
 
Bool IsZero () const
 Check if the location is zero. More...
 
Double GetDistance (const GeoLocation &location) const
 Calculate the distance from this location to a geo location. More...
 
Double GetBearing (const GeoLocation &location) const
 Calculate the bearing angle between this and a geo locations. More...
 
GeoLocation GetDestination (Double distance, Double bearing) const
 Calculate the destination geo location by a given distance and bearing from this location. More...
 

Static Public Member Functions

static Matrix GetRotationMatrix (const Input::AccelerationVector &acceleration, const Input::MagneticFieldVector &geomagnetic)
 Get the rotation matrix from acceleration and geomagnetic values. More...
 
static Vector GetRotationAngles (const Matrix &rotation)
 Get the geo rotation angles from a rotation matrix. More...
 

Public Attributes

Double mLatitude
 The latitude in degrees relative to the equator.
 
Double mLongitude
 The longitude in degrees relative to the zero meridian.
 
Double mAltitude
 The altitude above sea level in meters.
 
Double mRadius
 The sphere radius in meters, default is the idealized earth radius of 6371000 meters.
 

Detailed Description

The geo location class.

Constructor & Destructor Documentation

◆ GeoLocation()

Murl::Util::GeoLocation::GeoLocation ( Double  latitude,
Double  longitude,
Double  altitude 
)

The constructor taking separate location values.

Parameters
latitudeThe latitude in degrees relative to the equator.
longitudeThe longitude in degrees relative to the zero meridian.
altitudeThe altitude above sea level in meters.

Member Function Documentation

◆ GetRotationMatrix()

static Matrix Murl::Util::GeoLocation::GetRotationMatrix ( const Input::AccelerationVector acceleration,
const Input::MagneticFieldVector geomagnetic 
)
static

Get the rotation matrix from acceleration and geomagnetic values.

Parameters
accelerationThe acceleration vector.
geomagneticThe geomagnetic field vector.
Returns
The rotation matrix.

◆ GetRotationAngles()

static Vector Murl::Util::GeoLocation::GetRotationAngles ( const Matrix rotation)
static

Get the geo rotation angles from a rotation matrix.

Extracts the following rotation angles:

  • Sets the vector member x to the pitch angle.
  • Sets the vector member y to the roll angle.
  • Sets the vector member z to the azimuth angle.
    Parameters
    rotationThe rotation matrix, typically from GetRotationMatrix().
    Returns
    The geo rotation angles in radiants.

◆ IsZero()

Bool Murl::Util::GeoLocation::IsZero ( ) const

Check if the location is zero.

Returns
true if all location members are zero.

◆ GetDistance()

Double Murl::Util::GeoLocation::GetDistance ( const GeoLocation location) const

Calculate the distance from this location to a geo location.

The formula calculates on the basis of a spherical earth (ignoring ellipsoidal effects) which is accurate enough for most purposes. The altitude is not considered.
The calculation uses the simple spherical law of cosines formula.
distance = acos(sin(φ1) * sin(φ2) + cos(φ1) * cos(φ2) * cos(Δλ)) * earth radius.

Parameters
locationThe geo location.
Returns
The distance to the geo location in meters.

◆ GetBearing()

Double Murl::Util::GeoLocation::GetBearing ( const GeoLocation location) const

Calculate the bearing angle between this and a geo locations.

The formula calculates on the basis of a spherical earth (ignoring ellipsoidal effects) which is accurate enough for most purposes. The altitude is not considered.
The formula is for the initial bearing (sometimes referred to as forward azimuth) which if followed in a straight line along a great circle arc will take you from the start point to the end point.
θ = atan2(sin(Δλ) * cos(φ2), cos(φ1) * sin(φ2) − sin(φ1) * cos(φ2) * cos(Δλ)).

Parameters
locationThe geo location.
Returns
The bearing angle between this and the geo location in degrees in range [0 .. 360).

◆ GetDestination()

GeoLocation Murl::Util::GeoLocation::GetDestination ( Double  distance,
Double  bearing 
) const

Calculate the destination geo location by a given distance and bearing from this location.

The formula calculates on the basis of a spherical earth (ignoring ellipsoidal effects) which is accurate enough for most purposes.
Given a start point, initial bearing, and distance, this will calculate the destination point travelling along a great circle arc.
φ2 = asin(sin(φ1) * cos(d / R) + cos(φ1) * sin(d / R) * cos(θ))
λ2 = λ1 + atan2(sin(θ) * sin(d / R) * cos(φ1), cos(d / R) − sin(φ1) * sin(φ2))
φ is latitude, λ is longitude, θ is the bearing (clockwise from north), d is the distance, R is the earth’s radius (d / R is the angular distance).

Parameters
distanceThe distance to the destination geo location in meters.
bearingThe bearing to the destination geo location in degrees.
Returns
The destination geo location including the altitude from this location.

The documentation for this class was generated from the following file:
  • murl_util_geo_location.h


Copyright © 2011-2024 Spraylight GmbH.