polarTriangleArea static method

double polarTriangleArea(
  1. double tan1,
  2. double lng1,
  3. double tan2,
  4. double 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 double polarTriangleArea(
    double tan1, double lng1, double tan2, double lng2) {
  double deltaLng = lng1 - lng2;
  double t = tan1 * tan2;
  return 2 * atan2(t * sin(deltaLng), 1 + t * cos(deltaLng));
}