pub struct Aabb2 { /* private fields */ }Expand description
An axis-aligned bounding box represented by inclusive minimum and maximum corners.
Implementations§
Source§impl Aabb2
impl Aabb2
Sourcepub fn try_new(min: Point2, max: Point2) -> Result<Self, GeometryError>
pub fn try_new(min: Point2, max: Point2) -> Result<Self, GeometryError>
Creates a validated axis-aligned bounding box from ordered corners.
§Errors
Returns GeometryError::NonFiniteComponent when either corner
contains a non-finite coordinate.
Returns GeometryError::InvalidBounds when min is greater than
max on either axis.
Sourcepub const fn from_points(a: Point2, b: Point2) -> Self
pub const fn from_points(a: Point2, b: Point2) -> Self
Creates a bounding box from any two corners, normalizing axis order.
Sourcepub const fn from_point(point: Point2) -> Self
pub const fn from_point(point: Point2) -> Self
Creates the degenerate bounding box rooted at a single point.
Sourcepub fn contains_point(&self, point: Point2) -> bool
pub fn contains_point(&self, point: Point2) -> bool
Returns true when point lies inside or on the boundary.
Sourcepub fn contains_point_with_tolerance(
&self,
point: Point2,
tolerance: f64,
) -> Result<bool, GeometryError>
pub fn contains_point_with_tolerance( &self, point: Point2, tolerance: f64, ) -> Result<bool, GeometryError>
Returns true when point lies inside the box expanded by tolerance.
§Errors
Returns GeometryError::NonFiniteTolerance when tolerance is NaN
or infinite.
Returns GeometryError::NegativeTolerance when tolerance is negative.
Sourcepub fn is_degenerate(&self) -> bool
pub fn is_degenerate(&self) -> bool
Returns true when the box has zero width or height.
Sourcepub fn is_degenerate_with_tolerance(
&self,
tolerance: f64,
) -> Result<bool, GeometryError>
pub fn is_degenerate_with_tolerance( &self, tolerance: f64, ) -> Result<bool, GeometryError>
Returns true when the box width or height is within tolerance of zero.
§Errors
Returns GeometryError::NonFiniteTolerance when tolerance is NaN
or infinite.
Returns GeometryError::NegativeTolerance when tolerance is negative.