use crate::common::cubic_spline::CubicSpline;
use crate::geom3::Aabb3;
pub type CubicSpline3 = CubicSpline<3>;
impl CubicSpline3 {
pub fn aabb(&self) -> Aabb3 {
let (lo, hi) = self.compute_bounds();
Aabb3::new(lo, hi)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::Point3;
use approx::assert_relative_eq;
#[test]
fn aabb_matches_compute_bounds() {
let c = CubicSpline::new(
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 1.0, 0.0),
Point3::new(2.0, -1.0, 1.0),
Point3::new(3.0, 0.0, 0.0),
);
let (lo, hi) = c.compute_bounds();
let aabb = c.aabb();
assert_relative_eq!(aabb.mins, lo, epsilon = 1e-12);
assert_relative_eq!(aabb.maxs, hi, epsilon = 1e-12);
}
}