GreatCircle

Great-circle (shortest path on a sphere) math. WWK draws a shape's edges as great-circle arcs, which are NOT straight lines in latitude/longitude — over a long edge the two visibly differ — so anything that has to line up with a drawn edge must follow the arc, not the straight line.

Functions

Link copied to clipboard

The angle at the centre of the globe between a and b, in radians (0 for the same point, PI for opposite points): the length of the great-circle arc on a sphere of radius 1. Only lengths measured this way can be compared with each other, wherever the edges are.

Link copied to clipboard

The direction to take at from to go to to along the great circle, in radians clockwise from north (0 north, PI/2 east), between 0 and 2 PI. For two identical (or exactly opposite) points there is no direction and the answer is 0.

Link copied to clipboard
fun destination(from: GeoPosition, bearing: Double, angle: Double): GeoPosition

The point angle radians (an arc on a sphere of radius 1, see angleBetween) away from from, going bearing radians clockwise from north along a great circle. Altitude is from's.

Link copied to clipboard

The points strictly between from and to along the great circle joining them, spaced at most maxStepDegrees apart (and none at all if the edge is already shorter than that). Altitude goes straight from from's to to's. Two points that are identical or exactly opposite have no unique great circle; they yield no intermediate points.

Link copied to clipboard
fun pointAt(from: GeoPosition, to: GeoPosition, fraction: Double): GeoPosition

The point fraction (0 = from, 1 = to) of the way along the great-circle arc from from to to; altitude goes straight from one to the other. Two points that are identical or exactly opposite have no unique arc, the answer is then from.