Skip to main content

ray_triangle

Function ray_triangle 

Source
pub fn ray_triangle<S: RayReal>(
    origin: [S; 3],
    direction: [S; 3],
    a: [S; 3],
    b: [S; 3],
    c: [S; 3],
) -> Option<S>
Expand description

The ray parameter where the ray from origin along direction crosses triangle abc, negative for a crossing behind the origin; whether one behind counts is the caller’s to say. For a unit direction it is a distance. A ray parallel to the triangle’s plane, or a triangle with no area, is absent.

Edges and corners count, with RayReal::EDGE_SLACK of the triangle’s barycentric coordinates past them, so a ray through an edge two triangles share hits at least one of them and may hit both; a caller counting surfaces crossed keeps one crossing per distance.