Skip to main content

Module intersection

Module intersection 

Source
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§

TriangleHit
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 give None; tangent circles give one point (repeated).
line_line_2d
Intersection point of two infinite lines (point + direction); None if parallel.
line_plane_parameter
Where a ray (or line) meets a plane: the parameter t such that origin + t dir lies on the plane through plane_point with normal. None if parallel (including lying in the plane).
plane_plane
The line where two planes meet, as (point, unit direction); None if parallel.
ray_aabb
Ray-box intersection by the slab method: (t_near, t_far) with t_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) with t_far >= 0 (t_near is 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-b crosses or touches the plane in a single point.
segment_segment_2d
Intersection of segments a-b and c-d, including touching ends and collinear overlap.
segment_triangle
Segment-triangle intersection: the hit if the segment p-q reaches the triangle.
sphere_sphere
Whether two spheres/circles/balls overlap (touching counts).
triangle_plane
The intersection of triangle abc with 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, give None. Distances are signed against the plane through plane_point with normal; values within tol of zero count as on the plane.