Distance to simplicies
General interface
distancetosimplex
yields a distance and barycentric coordinates of the projection point.
DistanceQueries.distancetosimplex
— Functiond, λ = distancetosimplex(y, x::NTuple{M,SVector{N, T}})
Get the distance d::T
to the simplex spanned by M
points x
and barycentric coordinates λ::NTuple{N, T}
of the projection of y
.
Distance to tetrahedron.
Line segment
Compute distancetolinesegment
with projectontolinesegment
and projectontoline
.
In contrast to distancetosimplex
only one of the two (linearly dependent) barycentric coordinates, the line parameter t
, is returned.
DistanceQueries.distancetolinesegment
— Methodd, t = distancetolinesegment(x, (a,b))
Compute distance of x
to line segment (a,b)
.
Returns (d, t)
with distance d
and parameter 0 <= t <= 1
such that projection point is (1-t)*a + t*b
.
DistanceQueries.projectontoline
— Methodt, r = projectontoline(x, (a, b))
Project x
onto line (a, b)
. Returns (t, r)
for Π(x) = a + t*r
.
DistanceQueries.projectontolinesegment
— MethodΠ, t, r = projectontolinesegment(x, (a, b))
Project x
onto line segment (a, b)
.
Returns (Π(x), t, r)
for Π(x) = a + t*r
, 0 <= t <= 1
.
Triangle
Compute distancetotriangle
with projection point in barycentriccoordinates
.
DistanceQueries.barycentriccoordinates
— Methodλ = barycentriccoordinates(x, (a,b,c)) # in 2d
Compute barycentric coordinates of x
w.r.t. to planar triangle (a,b,c)
.
This function will always return finite barycentric coordinates, even if the triangle is degenerated.
DistanceQueries.distancetotriangle
— Functiond, λ = distancetotriangle(x, (a,b,c))
d, λ = distancetotriangle(::Val{2}, x, (a,b,c)) # in 2d
d, λ = distancetotriangle(::Val{3}, x, (a,b,c)) # in 3d
Compute distance of x
to triangle (a,b,c)
.
Returns (d, λ)
with distance d
and barycentric coordinates λ
.