pub struct Aabb { /* private fields */ }Expand description
An axis-aligned box, or the empty box.
The empty box is a distinct state rather than a degenerate one with reversed bounds: “no points at all” and “a box of zero size at the origin” answer containment questions differently, and conflating them makes an empty shape appear to be at the origin.
Implementations§
Source§impl Aabb
impl Aabb
Sourcepub fn of_corners(a: Point, b: Point) -> Self
pub fn of_corners(a: Point, b: Point) -> Self
A box spanning two corners, in either order.
Sourcepub fn extent_max(&self) -> f64
pub fn extent_max(&self) -> f64
The length of the longest axis, or zero if empty.
Sourcepub fn with_point(&self, p: Point) -> Self
pub fn with_point(&self, p: Point) -> Self
This box grown to include p.
Sourcepub fn expanded(&self, margin: f64) -> Self
pub fn expanded(&self, margin: f64) -> Self
This box grown by margin in every direction.
The usual way to account for a tolerance before a rejection test: two shapes whose boxes miss by less than their tolerances may still touch.
Sourcepub fn with_tolerance(&self, tol: Tolerances) -> Self
pub fn with_tolerance(&self, tol: Tolerances) -> Self
This box grown by the confusion tolerance.
Sourcepub fn contains_box(&self, other: &Self) -> bool
pub fn contains_box(&self, other: &Self) -> bool
Whether other lies entirely inside this box.
Sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Whether the two boxes share any point.
The rejection test everything else is built on. An empty box intersects nothing.
Sourcepub fn intersection(&self, other: &Self) -> Self
pub fn intersection(&self, other: &Self) -> Self
The overlap of two boxes, or empty if they do not meet.
Sourcepub fn distance_to(&self, p: Point) -> f64
pub fn distance_to(&self, p: Point) -> f64
The shortest distance from p to this box, zero if inside.
Sourcepub fn distance_to_box(&self, other: &Self) -> f64
pub fn distance_to_box(&self, other: &Self) -> f64
A lower bound on the distance between two boxes, zero if they meet.
A bound, not the distance between the shapes inside them, which is why it is only ever useful for rejection: if this exceeds a threshold the shapes certainly do too.
Sourcepub fn transformed(&self, t: &Transform) -> Self
pub fn transformed(&self, t: &Transform) -> Self
This box transformed, as the box of the transformed corners.
The result contains the transformed box but is generally larger than the tightest one: a rotated box is not axis-aligned, and its bounding box must cover the rotation. Erring outward is the safe direction, and repeatedly transforming a box therefore inflates it; transform the geometry and re-bound instead of chaining this.
Trait Implementations§
impl Copy for Aabb
Source§impl FromIterator<Point> for Aabb
impl FromIterator<Point> for Aabb
impl StructuralPartialEq for Aabb
Auto Trait Implementations§
impl Freeze for Aabb
impl RefUnwindSafe for Aabb
impl Send for Aabb
impl Sync for Aabb
impl Unpin for Aabb
impl UnsafeUnpin for Aabb
impl UnwindSafe for Aabb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.