Skip to content

Commit

Permalink
Public export of BoundingBox
Browse files Browse the repository at this point in the history
Renamed from Aabb
  • Loading branch information
cedricchevalier19 committed May 11, 2022
1 parent 75f2580 commit 384c08a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub type PointND<const D: usize> = SVector<f64, D>;
pub type Matrix<const D: usize> = SMatrix<f64, D, D>;

#[derive(Debug, Clone)]
pub struct Aabb<const D: usize> {
pub struct BoundingBox<const D: usize> {
p_min: PointND<D>,
p_max: PointND<D>,
}

impl<const D: usize> Aabb<D> {
impl<const D: usize> BoundingBox<D> {
pub fn p_min(&self) -> &PointND<D> {
&self.p_min
}
Expand Down Expand Up @@ -192,13 +192,13 @@ impl<const D: usize> Aabb<D> {
/// Minimum bounding rectangle.
#[derive(Debug, Clone)]
pub(crate) struct Mbr<const D: usize> {
aabb: Aabb<D>,
aabb: BoundingBox<D>,
aabb_to_mbr: Matrix<D>,
mbr_to_aabb: Matrix<D>,
}

impl<const D: usize> Mbr<D> {
pub fn aabb(&self) -> &Aabb<D> {
pub fn aabb(&self) -> &BoundingBox<D> {
&self.aabb
}

Expand All @@ -222,7 +222,7 @@ impl<const D: usize> Mbr<D> {
let base_change = householder_reflection(&vec);
let mbr_to_aabb = base_change.try_inverse().unwrap();
let mapped = points.par_iter().map(|p| mbr_to_aabb * p);
let aabb = Aabb::from_points(mapped);
let aabb = BoundingBox::from_points(mapped);

Self {
aabb,
Expand Down Expand Up @@ -362,7 +362,7 @@ mod tests {
Point2D::from([4., 5.]),
];

let aabb = Aabb::from_points(points);
let aabb = BoundingBox::from_points(points);

assert_ulps_eq!(aabb.p_min, Point2D::from([0., 0.]));
assert_ulps_eq!(aabb.p_max, Point2D::from([5., 5.]));
Expand All @@ -371,14 +371,14 @@ mod tests {
#[test]
#[should_panic]
fn test_aabb2d_invalid_input_1() {
let _aabb = Aabb::<2>::from_points([]);
let _aabb = BoundingBox::<2>::from_points([]);
}

#[test]
#[should_panic]
fn test_aabb2d_invalid_input_2() {
let points = [Point2D::from([5., -9.2])];
let _aabb = Aabb::from_points(points);
let _aabb = BoundingBox::from_points(points);
}

#[test]
Expand Down Expand Up @@ -521,7 +521,7 @@ mod tests {
Point3D::from([4., 5., 3.]),
];

let aabb = Aabb::from_points(points);
let aabb = BoundingBox::from_points(points);

assert_ulps_eq!(aabb.p_min, Point3D::from([0., 0., -2.]));
assert_ulps_eq!(aabb.p_max, Point3D::from([5., 5., 5.]));
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub mod topology;
mod work_share;

pub use crate::algorithms::*;
pub use crate::geometry::{Point2D, Point3D, PointND};
pub use crate::geometry::{BoundingBox, Point2D, Point3D, PointND};
pub use crate::real::Real;

// Internal use
Expand Down
2 changes: 1 addition & 1 deletion tools/src/bin/medit2svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ where
mesh.node_count(),
)
};
let aabb = coupe::Aabb::<2>::from_points(coordinates.par_iter().cloned());
let aabb = coupe::BoundingBox::<2>::from_points(coordinates.par_iter().cloned());
let [xmin, ymin] = <[f64; 2]>::from(*aabb.p_min());
let [xmax, ymax] = <[f64; 2]>::from(*aabb.p_max());
let width = xmax - xmin;
Expand Down

0 comments on commit 384c08a

Please sign in to comment.