Function continuous_line3_aabb3

Source
pub fn continuous_line3_aabb3<S>(
    line: &Line3<S>,
    aabb: &Aabb3<S>,
) -> Option<((S, Point3<S>), (S, Point3<S>))>
where S: Real + Float + RelativeEq<Epsilon = S> + Debug,
Expand description

Compute the intersection of a 3D line with a 3D AABB.

If the line and AABB intersect, the two intersection points are returned with the scalar parameter corresponding to that point along the line.

let aabb = Aabb3::with_minmax (
  [-1.0, -1.0, -1.0].into(), [1.0, 1.0, 1.0].into());
let line = Line3::new  ([0.0, 0.0, 0.0].into(), Unit3::axis_x());
assert_eq!(
  continuous_line3_aabb3 (&line, &aabb).unwrap(),
  ( (-1.0, [-1.0, 0.0, 0.0].into()),
    ( 1.0, [ 1.0, 0.0, 0.0].into())
  )
);

Returns None if the line and AABB are tangent:

let aabb = Aabb3::with_minmax (
  [-1.0, -1.0, -1.0].into(), [1.0, 1.0, 1.0].into());
let line = Line3::new  ([0.0, 1.0, 0.0].into(), Unit3::axis_x());
assert_eq!(continuous_line3_aabb3 (&line, &aabb), None);