pub struct BoundingBox {
pub points: Vec<Point>,
}Expand description
A bounding box represented by a collection of points.
Fields§
§points: Vec<Point>The points that define the bounding box.
Implementations§
Source§impl BoundingBox
impl BoundingBox
Sourcepub fn from_coords(x1: f32, y1: f32, x2: f32, y2: f32) -> Self
pub fn from_coords(x1: f32, y1: f32, x2: f32, y2: f32) -> Self
Creates a bounding box from coordinates.
§Arguments
x1- The x-coordinate of the top-left corner.y1- The y-coordinate of the top-left corner.x2- The x-coordinate of the bottom-right corner.y2- The y-coordinate of the bottom-right corner.
§Returns
A new BoundingBox instance representing a rectangle.
Sourcepub fn from_contour(contour: &Contour<u32>) -> Self
pub fn from_contour(contour: &Contour<u32>) -> Self
Sourcepub fn area(&self) -> f32
pub fn area(&self) -> f32
Calculates the area of the bounding box using the shoelace formula.
§Returns
The area of the bounding box. Returns 0.0 if the bounding box has fewer than 3 points.
Sourcepub fn x_min(&self) -> f32
pub fn x_min(&self) -> f32
Gets the minimum x-coordinate of all points in the bounding box.
§Returns
The minimum x-coordinate, or 0.0 if there are no points.
Sourcepub fn y_min(&self) -> f32
pub fn y_min(&self) -> f32
Gets the minimum y-coordinate of all points in the bounding box.
§Returns
The minimum y-coordinate, or 0.0 if there are no points.
Sourcepub fn get_min_area_rect(&self) -> MinAreaRect
pub fn get_min_area_rect(&self) -> MinAreaRect
Computes the minimum area rectangle that encloses the bounding box.
This method uses the rotating calipers algorithm on the convex hull of the bounding box to find the minimum area rectangle.
§Returns
A MinAreaRect representing the minimum area rectangle. If the bounding box has fewer than
3 points, returns a rectangle with zero dimensions.
Sourcepub fn approx_poly_dp(&self, epsilon: f32) -> BoundingBox
pub fn approx_poly_dp(&self, epsilon: f32) -> BoundingBox
Trait Implementations§
Source§impl Clone for BoundingBox
impl Clone for BoundingBox
Source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoundingBox
impl Debug for BoundingBox
Source§impl<'de> Deserialize<'de> for BoundingBox
impl<'de> Deserialize<'de> for BoundingBox
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for BoundingBox
impl RefUnwindSafe for BoundingBox
impl Send for BoundingBox
impl Sync for BoundingBox
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.