Skip to content

@saehrimnir/druidjs / haversine

Function: haversine()

ts
function haversine(a: number[] | Float64Array<ArrayBufferLike>, b: number[] | Float64Array<ArrayBufferLike>): number;

Defined in: metrics/haversine.js:10

Computes the Haversine distance between two points on a sphere of unit length 1. Multiply the result with the radius of the sphere. (For instance Earth's radius is 6371km)

Parameters

ParameterTypeDescription
anumber[] | Float64Array<ArrayBufferLike>Point [lat1, lon1] in radians
bnumber[] | Float64Array<ArrayBufferLike>Point [lat2, lon2] in radians

Returns

number

The Haversine distance between a and b.

See

https://en.wikipedia.org/wiki/Haversine_formula