Distances

Distances are functors that are evaluated with a pair of geometries. The definition that is used depends on the manifold of the geometries, which is available at compile time.

Meshes.EuclideanDistance — Type
EuclideanDistance()

Length of the straight line connecting two points in the space where they are embedded. For points on the ellipsoid (🌐) this is the chord through the interior of the ellipsoid, which is shorter than any path along the surface.

See also GeodesicDistance.

Examples

d = EuclideanDistance()

d(Point(0, 0), Point(1, 1))

d(Point(LatLon(0, 0)), Point(LatLon(0, 1)))
source
Meshes.MahalanobisDistance — Type
MahalanobisDistance(matrix)

A Mahalanobis distance defined by a positive semidefinite symmetric matrix. Given two points p and q, it is defined as √((p - q)' * matrix * (p - q)).

MahalanobisDistance(radii, rotation=I)

Alternatively, construct the matrix based on radii for rotated axes that are defined by a rotation specification from the package Rotations.jl.

source
Meshes.GeodesicDistance — Type
GeodesicDistance()

Length of the shortest path along the manifold of two points. In Euclidean space (𝔼) this is the straight line connecting them. On the ellipsoid (🌐) this is the geodesic of the ellipsoid attached to the datum of the coordinate reference system, and is computed with the series of Karney (2013).

See also EuclideanDistance.

Examples

d = GeodesicDistance()

d(Point(LatLon(0, 0)), Point(LatLon(0, 1)))

References

source

In Euclidean space the Euclidean distance is the length of the straight line connecting the points:

d = EuclideanDistance()

d(Point(0, 0), Point(3, 4))
5.0 m

On the ellipsoid the same distance is the chord that goes through the interior of the Earth, whereas the geodesic distance is the length of the shortest path along the surface:

sydney = Point(LatLon(-33.8688, 151.2093))
london = Point(LatLon(51.5074, -0.1278))

euclidean = EuclideanDistance()
geodesic = GeodesicDistance()

euclidean(sydney, london), geodesic(sydney, london)
(1.2379161016808214e7 m, 1.698929577054045e7 m)

The ellipsoid is taken from the datum of the coordinate reference system, so all parameters are retrieved automatically for the user.

For geometries that are not points, the distance is computed between the nearest points. Consider the Euclidean distance between a point and a segment:

euclidean(Point(0, 0), Segment((1, 1), (2, 2)))
1.4142135623730951 m

or between two infinite parallel lines:

euclidean(Line((0, 0), (1, 1)), Line((0, 1), (1, 2)))
0.7071067811865476 m