The native SDK exposes both the fast spherical approximation and the more accurate ellipsoidal solver, each between every row and every column of two packed point sets.
Inputs are in radians.
Outputs are in meters.
// Statue of Liberty (40.6892°N, 74.0445°W) and Big Ben (51.5007°N, 0.1246°W)nk_f64_t latitudes[] = {0.7101605100, 0.8988567821}, longitudes[] = {-1.2923203180, -0.0021746802};// A pack is built once per point set, on an `nk_default_alignment_k` boundarynk_size_t bytes = 0;nk_vincentys_pack_size_f64_best(2, capabilities, &bytes);void *vincentys_pack = aligned_alloc(nk_default_alignment_k, bytes);nk_vincentys_pack_f64_best(latitudes, longitudes, 2, vincentys_pack, capabilities, NULL);// Every row against every column, so the diagonal is zeronk_f64_t distances[2][2];nk_vincentys_packed_f64_best(vincentys_pack, vincentys_pack, &distances[0][0], 2 * sizeof(nk_f64_t), capabilities, NULL); // distances[0][1] ≈ 5,589,857 m on WGS-84nk_haversines_pack_size_f64_best(2, capabilities, &bytes);void *haversines_pack = aligned_alloc(nk_default_alignment_k, bytes);nk_haversines_pack_f64_best(latitudes, longitudes, 2, haversines_pack, capabilities, NULL);nk_haversines_packed_f64_best(haversines_pack, haversines_pack, &distances[0][0], 2 * sizeof(nk_f64_t), capabilities, NULL); // distances[0][1] ≈ 5,574,848 m on the mean sphere, 15 km less
API
Functions
haversinesGreat-circle metres between every row and every column point on the mean sphere, through the haversine 2R · atan2(√h, √(1 − h)) evaluated in precision_type_, where h = sin²(Δφ / 2) + cos φ₁ · cos φ₂ · sin²(Δλ / 2).
The [rows,columns] distances, results_stride bytes apart.
results_stride
in
Bytes between the rows of results.
vincentysGeodesic metres on the WGS-84 ellipsoid between every row and every column point, through Vincenty's inverse formula in precision_type_, with the reduced latitudes taken through atan2 to stay finite at the poles; parameters as haversines.
vincentys_packPacks points as their longitudes and the sines and cosines of their reduced latitudes, for vincentys_packed, taking what haversines_pack takes.
vincentys_packedGeodesic metres on the WGS-84 ellipsoid between every row and every column point of two Vincenty packs, taking what haversines_packed takes.
clearances_packedClearances in metres from every row viewpoint to every column target over one terrain, as nk_clearances_packed_f32_best defines them, dispatched as terrain_pack is.