Skip to main content

ray_triangle3d_collision

Function ray_triangle3d_collision 

Source
pub fn ray_triangle3d_collision(
    ray_origin: &[f64; 3],
    ray_direction: &[f64; 3],
    triangle: &Triangle3D,
) -> Option<(f64, [f64; 3], [f64; 3])>
Expand description

Tests if a ray intersects a 3D triangle and returns the distance to intersection, hit point and barycentric coordinates

§Arguments

  • ray_origin - The origin of the ray [x, y, z]
  • ray_direction - The direction of the ray [dx, dy, dz] (must be normalized)
  • triangle - The 3D triangle to test against

§Returns

Some((distance, hit_point, barycentric)) if the ray intersects the triangle, None otherwise