Murl Engine Lua Addon API  Version 1.0 beta
Murl.Util.GeoLocation

The geo location class.


Table members

Functions


Murl.Util.GeoLocation.GetRotationMatrix(acceleration, geomagnetic)

Get the rotation matrix from acceleration and geomagnetic values.

Murl.Math.Matrix GetRotationMatrix(Murl.Math.Vector acceleration, Murl.Math.Vector geomagnetic)

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

Murl.Util.GeoLocation.GetRotationAngles(rotation)

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.

Murl.Math.Vector GetRotationAngles(Murl.Math.Matrix rotation)

Parameters
rotationThe rotation matrix, typically from GetRotationMatrix().
Returns
Murl.Math.Vector The geo rotation angles in radiants.

Murl.Util.GeoLocation.new()

The default constructor.

Murl.Util.GeoLocation new()

Returns
Murl.Util.GeoLocation

Murl.Util.GeoLocation.new(latitude, longitude, altitude)

The constructor taking separate location values.

Murl.Util.GeoLocation new(Number latitude, Number longitude, Number altitude)

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.
Returns
Murl.Util.GeoLocation


Methods


IsZero()

Check if the location is zero.

Boolean IsZero()

Returns
Boolean true if all location members are zero.

GetDistance(location)

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.

Number GetDistance(Murl.Util.GeoLocation location)

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

GetBearing(location)

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(Δλ)).

Number GetBearing(Murl.Util.GeoLocation location)

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

GetDestination(distance, bearing)

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).

Murl.Util.GeoLocation GetDestination(Number distance, Number bearing)

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


Instance Members


mLatitude

The latitude in degrees relative to the equator.

Returns
Number

mLongitude

The longitude in degrees relative to the zero meridian.

Returns
Number

mAltitude

The altitude above sea level in meters.

Returns
Number

mRadius

The sphere radius in meters, default is the idealized earth radius of 6371000 meters.

Returns
Number