pub struct BBox {
pub min_x: f64,
pub min_y: f64,
pub max_x: f64,
pub max_y: f64,
}Expand description
An axis-aligned bounding box, stored as its minimum corner plus its extent.
The min / max form (rather than x / y / width / height)
keeps the empty-box case representable: a box that has not been
extended yet is min > max on every axis, which is the standard
sentinel for “no geometry yet”.
Fields§
§min_x: f64The smallest x reached by the geometry.
min_y: f64The smallest y reached by the geometry.
max_x: f64The largest x reached by the geometry.
max_y: f64The largest y reached by the geometry.
Implementations§
Source§impl BBox
Inherent implementation of BBox.
impl BBox
Inherent implementation of BBox.
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Returns an empty bounding box.
The empty box has min greater than max on both axes, which
makes BBox::extend_point work without a special case for the
first vertex.
Sourcepub fn from_min_size(min_x: f64, min_y: f64, width: f64, height: f64) -> Self
pub fn from_min_size(min_x: f64, min_y: f64, width: f64, height: f64) -> Self
Returns a bounding box from its minimum corner and its extent.
§Arguments
f64- A 64-bit float (f64).
Sourcepub fn extend_point(&mut self, x: f64, y: f64)
pub fn extend_point(&mut self, x: f64, y: f64)
Sourcepub fn extend_box(&mut self, other: &BBox)
pub fn extend_box(&mut self, other: &BBox)
Sourcepub fn intersects(&self, other: &BBox) -> bool
pub fn intersects(&self, other: &BBox) -> bool
Sourcepub fn intersection(&self, other: &BBox) -> Option<BBox>
pub fn intersection(&self, other: &BBox) -> Option<BBox>
Source§impl BBox
impl BBox
pub fn get_min_x(&self) -> f64
pub fn get_mut_min_x(&mut self) -> &mut f64
pub fn set_min_x(&mut self, val: f64) -> &mut Self
pub fn get_min_y(&self) -> f64
pub fn get_mut_min_y(&mut self) -> &mut f64
pub fn set_min_y(&mut self, val: f64) -> &mut Self
pub fn get_max_x(&self) -> f64
pub fn get_mut_max_x(&mut self) -> &mut f64
pub fn set_max_x(&mut self, val: f64) -> &mut Self
pub fn get_max_y(&self) -> f64
pub fn get_mut_max_y(&mut self) -> &mut f64
pub fn set_max_y(&mut self, val: f64) -> &mut Self
Trait Implementations§
impl Copy for BBox
impl StructuralPartialEq for BBox
Auto Trait Implementations§
impl Freeze for BBox
impl RefUnwindSafe for BBox
impl Send for BBox
impl Sync for BBox
impl Unpin for BBox
impl UnsafeUnpin for BBox
impl UnwindSafe for BBox
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
Mutably borrows from an owned value. Read more