Formula 1.0.0

hirondelle.formula.function.builtin
Class Bearing

Object
  extended by hirondelle.formula.function.builtin.Bearing
All Implemented Interfaces:
Function

public final class Bearing
extends Object
implements Function

bearing(φ1, λ1, φ2, λ2): the compass bearing from one place to another.


Constructor Summary
Bearing()
           
 
Method Summary
 Decimal calculate(Decimal... aArgs)
          The bearing is the direction one must travel from a specific starting point (point 1) to get to a specific destination (point 2).
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bearing

public Bearing()
Method Detail

calculate

public Decimal calculate(Decimal... aArgs)
The bearing is the direction one must travel from a specific starting point (point 1) to get to a specific destination (point 2).

Returns degrees from true north, positive towards the east, in the range 0..360.

This method takes 4 parameters, in the following order:

Latitude is positive north of the equator, and negative south of the equator. Longitude is positive to the east of Greenwich meridian (Asia, for example), and negative to the west of the Greenwich meridian (America, for example).

The return value usually has a large number of decimal places. That precision is spurious and without physical significance, since the underlying implementation makes the approximation that the Earth is spherical.

The caller should round the result to a reasonable number of decimal places. (Some applications may even decide to round the result to an integer.)

For reference, the crux of the formula is:

atan2(sin(Δλ) * cos(φ2), cos(φ1) * sin(φ2) - sin(φ1) * cos(φ2) * cos(Δλ)

Specified by:
calculate in interface Function
Parameters:
aArgs - 0 or more arguments to the function.

Formula 1.0.0

Copyright Hirondelle Systems. Published January 31, 2013