Expand description
Intersection tests and constructions between common primitives.
Points and vectors are [f64; 2] / [f64; 3] arrays. Parallel and touching configurations
are handled explicitly; tolerances are absolute and stated per function where they matter.
See the book entry Intersections and closest points.
Structs§
- Triangle
Hit - A ray-triangle hit: distance along the ray and barycentric weights of the hit point.
Enums§
- Intersection2D
- Result of intersecting two segments or lines in the plane.
Functions§
- aabb_
aabb - Whether two axis-aligned boxes overlap (touching counts).
- circle_
circle - The (up to two) intersection points of two circles,
(centre, radius). Coincident circles giveNone; tangent circles give one point (repeated). - line_
line_ 2d - Intersection point of two infinite lines (point + direction);
Noneif parallel. - line_
plane_ parameter - Where a ray (or line) meets a plane: the parameter
tsuch thatorigin + t dirlies on the plane throughplane_pointwithnormal.Noneif parallel (including lying in the plane). - plane_
plane - The line where two planes meet, as
(point, unit direction);Noneif parallel. - ray_
aabb - Ray-box intersection by the slab method:
(t_near, t_far)witht_far >= max(t_near, 0). - ray_
plane - Ray-plane intersection point (
t >= 0). - ray_
sphere - Ray-sphere intersection: the entry and exit parameters
(t_near, t_far)witht_far >= 0(t_nearis negative when the origin is inside). - ray_
triangle - Ray-triangle intersection by the Möller-Trumbore algorithm. Both faces are hit;
t >= 0. - segment_
plane - Segment-plane intersection point, if the segment
a-bcrosses or touches the plane in a single point. - segment_
segment_ 2d - Intersection of segments
a-bandc-d, including touching ends and collinear overlap. - segment_
triangle - Segment-triangle intersection: the hit if the segment
p-qreaches the triangle. - sphere_
sphere - Whether two spheres/circles/balls overlap (touching counts).
- triangle_
plane - The intersection of triangle
abcwith a plane as a segment(p, q), if the plane cuts the triangle properly (crosses it, or contains exactly one of its edges). Triangles lying in the plane, or touching it at a single vertex, giveNone. Distances are signed against the plane throughplane_pointwithnormal; values withintolof zero count as on the plane.