polarTriangleArea static method

num polarTriangleArea(
  1. num tan1,
  2. num lng1,
  3. num tan2,
  4. num lng2,
)

Returns the signed area of a triangle which has North Pole as a vertex. Formula derived from 'Area of a spherical triangle given two edges and the included angle' as per 'Spherical Trigonometry' by Todhunter, page 71, section 103, point 2.

See http://books.google.com/books?id=3uBHAAAAIAAJ&pg=PA71

The arguments named 'tan' are tan((pi/2 - x)/2).

Implementation

static num polarTriangleArea(num tan1, num lng1, num tan2, num lng2) {
  num deltaLng = lng1 - lng2;
  num t = tan1 * tan2;
  return 2 * atan2(t * sin(deltaLng), 1 + t * cos(deltaLng));
}