Struct visioncortex::bound::BoundingRect
source · pub struct BoundingRect {
pub left: i32,
pub top: i32,
pub right: i32,
pub bottom: i32,
}
Expand description
The rectangle that bounds an object
Fields§
§left: i32
§top: i32
§right: i32
§bottom: i32
Implementations§
source§impl BoundingRect
impl BoundingRect
pub fn new_x_y_w_h(x: i32, y: i32, w: i32, h: i32) -> Self
pub fn width(self) -> i32
pub fn height(self) -> i32
pub fn is_empty(self) -> bool
pub fn center(self) -> PointI32
pub fn left_top(&self) -> PointI32
pub fn top_left(&self) -> PointI32
pub fn top_right(&self) -> PointI32
pub fn bottom_left(&self) -> PointI32
pub fn right_bottom(&self) -> PointI32
pub fn bottom_right(&self) -> PointI32
sourcepub fn sq_dist(self, other: Self) -> i32
pub fn sq_dist(self, other: Self) -> i32
Calculates the squared distance betweeen the center of two BoundingRect
s.
pub fn aspect_ratio(self) -> f64
pub fn aspect_ratio_doubled(self) -> i32
pub fn add_x_y(&mut self, x: i32, y: i32)
pub fn merge(&mut self, other: Self)
pub fn clear(&mut self)
pub fn hit(self, other: Self) -> bool
pub fn clip(&mut self, other: Self)
pub fn squared(self) -> Self
pub fn translate(&mut self, p: PointI32)
sourcepub fn have_point_on_boundary(&self, p: PointI32, tolerance: usize) -> bool
pub fn have_point_on_boundary(&self, p: PointI32, tolerance: usize) -> bool
Tolerance means:
1. Extend each boundary on both sides by tolerance
units along its direction.
2. true
is returned iff p
lies on either one of the extended boundaries.
A point p
lying on boundary “strictly” means this function returns true with p
and tolerance
set as 0.
pub fn have_point_inside(&self, p: PointI32) -> bool
sourcepub fn have_point_on_boundary_or_inside(
&self,
p: PointI32,
boundary_tolerance: usize
) -> bool
pub fn have_point_on_boundary_or_inside( &self, p: PointI32, boundary_tolerance: usize ) -> bool
For definition of boundary_tolerance
, see BoundingRect::have_point_on_boundary().
sourcepub fn get_closest_point_inside(&self, p: PointI32) -> PointI32
pub fn get_closest_point_inside(&self, p: PointI32) -> PointI32
Given a point on the boundary, return the closest point inside the bounding rect. The behavior is undefined unless ‘p’ is a point on boundary (strictly) and the area of this rect is larger than 1.
sourcepub fn get_closest_point_outside(&self, p: PointI32) -> PointI32
pub fn get_closest_point_outside(&self, p: PointI32) -> PointI32
Given a point on the boundary, return the closest point outside the bounding rect. Note that if ‘p’ is a corner, there are three closest points, but the diagonal one is always returned. The behavior is undefined unless ‘p’ is a point on boundary (strictly).
Trait Implementations§
source§impl Bound for BoundingRect
impl Bound for BoundingRect
source§impl Clone for BoundingRect
impl Clone for BoundingRect
source§fn clone(&self) -> BoundingRect
fn clone(&self) -> BoundingRect
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BoundingRect
impl Debug for BoundingRect
source§impl Default for BoundingRect
impl Default for BoundingRect
source§fn default() -> BoundingRect
fn default() -> BoundingRect
source§impl PartialEq for BoundingRect
impl PartialEq for BoundingRect
source§fn eq(&self, other: &BoundingRect) -> bool
fn eq(&self, other: &BoundingRect) -> bool
self
and other
values to be equal, and is used
by ==
.