pub struct BoundingBox {
pub xmin: f32,
pub ymin: f32,
pub xmax: f32,
pub ymax: f32,
}Expand description
A bounding box with f32 coordinates in XYXY format
Fields§
§xmin: f32left-most normalized coordinate of the bounding box
ymin: f32top-most normalized coordinate of the bounding box
xmax: f32right-most normalized coordinate of the bounding box
ymax: f32bottom-most normalized coordinate of the bounding box
Implementations§
Source§impl BoundingBox
impl BoundingBox
Sourcepub fn new(xmin: f32, ymin: f32, xmax: f32, ymax: f32) -> Self
pub fn new(xmin: f32, ymin: f32, xmax: f32, ymax: f32) -> Self
Creates a new BoundingBox from the given coordinates
Sourcepub fn to_canonical(&self) -> Self
pub fn to_canonical(&self) -> Self
Transforms BoundingBox so that xmin <= xmax and ymin <= ymax
let bbox = BoundingBox::new(0.8, 0.6, 0.4, 0.2);
let canonical_bbox = bbox.to_canonical();
assert_eq!(canonical_bbox, BoundingBox::new(0.4, 0.2, 0.8, 0.6));Trait Implementations§
Source§impl Clone for BoundingBox
impl Clone for BoundingBox
Source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BoundingBox
impl Debug for BoundingBox
Source§impl Default for BoundingBox
impl Default for BoundingBox
Source§fn default() -> BoundingBox
fn default() -> BoundingBox
Returns the “default value” for a type. Read more
Source§impl From<BoundingBox> for [f32; 4]
impl From<BoundingBox> for [f32; 4]
Source§fn from(b: BoundingBox) -> Self
fn from(b: BoundingBox) -> Self
Converts a BoundingBox into an array of 4 f32 values in xmin, ymin, xmax, ymax order
§Examples
let bbox = BoundingBox {
xmin: 0.1,
ymin: 0.2,
xmax: 0.3,
ymax: 0.4,
};
let arr: [f32; 4] = bbox.into();
assert_eq!(arr, [0.1, 0.2, 0.3, 0.4]);Source§impl PartialEq for BoundingBox
impl PartialEq for BoundingBox
impl Copy for BoundingBox
impl StructuralPartialEq for BoundingBox
Auto Trait Implementations§
impl Freeze for BoundingBox
impl RefUnwindSafe for BoundingBox
impl Send for BoundingBox
impl Sync for BoundingBox
impl Unpin for BoundingBox
impl UnsafeUnpin for BoundingBox
impl UnwindSafe for BoundingBox
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more