Expand description
Closest-point queries: the point of a primitive nearest to a query point.
Points and vectors are plain [f64; D] arrays. Every query returns the closest point together
with whatever parameterisation is natural for the primitive (a segment parameter, barycentric
coordinates, …), and distances are Euclidean. For nearest neighbours within a large point
set, build a KdTree instead.
See the book entry Intersections and closest points.
Structs§
- Closest
- A closest point and its distance from the query.
Functions§
- closest_
point_ on_ aabb - The closest point in the axis-aligned box
[min, max](the point itself if inside). - closest_
point_ on_ line - The closest point on the infinite line through
originwith directiondir, and its (unclamped) parameter. A zero direction returnsorigin. - closest_
point_ on_ mesh - The closest point on a triangle mesh (brute force over triangles) with the triangle index.
Triangles index into
vertices;Nonefor an empty mesh or out-of-range indices. - closest_
point_ on_ plane - The closest point on a plane given by a point on it and a normal (need not be unit); also the
signed distance (positive on the side the normal points to).
Nonefor a zero normal. - closest_
point_ on_ polygon_ boundary - The closest point on the boundary of a closed polygon (its last vertex joins the first).
- closest_
point_ on_ polyline - The closest point on a polyline’s segments, with the index of the segment it lies on and the
parameter along it.
Noneif there are fewer than two vertices. - closest_
point_ on_ ray - The closest point on the ray from
originalongdir(parametert >= 0). - closest_
point_ on_ segment - The closest point on segment
a-b, and its parametertin[0, 1](a + t (b - a)). A degenerate segment (a == b) returnsawitht = 0. - closest_
point_ on_ sphere - The closest point on the surface of a sphere (the centre direction is arbitrary if
pis at the centre: the +x pole is returned). - closest_
point_ on_ triangle - The closest point on the (filled) triangle
abcin 3D, with its barycentric coordinates[wa, wb, wc](non-negative, summing to 1). Works for degenerate triangles too. - closest_
points_ between_ segments - The closest points between segments
p1-q1andp2-q2:(point on first, point on second, distance); the segments may be degenerate (points). Ericson 5.1.9. - distance_
point_ to_ line_ 3d - The distance from
pto the infinite 3D line throughaandb(the point distance toaif they coincide).