Struct quadtree_rs::area::Area
source · pub struct Area<U>where
U: PrimInt + Default + PartialOrd,{ /* private fields */ }
Expand description
A rectangular region in 2d space.
Lightweight, should be passed by value. Defined by its top-left anchor, width, and height.
NB:
- The top-left anchor can be any valid
(U, U)
coordinate, positive or negative, in any quadrant. - The width and height must both be positive and nonzero.
Implementations§
source§impl<U> Area<U>where
U: PrimInt + Default,
impl<U> Area<U>where U: PrimInt + Default,
sourcepub fn bottom_edge(&self) -> U
pub fn bottom_edge(&self) -> U
The coordinate of the bottom edge of the region.
sourcepub fn right_edge(&self) -> U
pub fn right_edge(&self) -> U
The coordinate of the right edge of the region.
sourcepub fn intersects(self, other: Self) -> bool
pub fn intersects(self, other: Self) -> bool
Whether or not an area intersects another area.
sourcepub fn contains(self, other: Self) -> bool
pub fn contains(self, other: Self) -> bool
Whether or not an area wholly contains another area.
sourcepub fn contains_pt(self, pt: Point<U>) -> bool
pub fn contains_pt(self, pt: Point<U>) -> bool
Whether or not an area contains a point.
Trait Implementations§
source§impl<U> From<Area<U>> for ((U, U), (U, U))where
U: PrimInt + Default,
impl<U> From<Area<U>> for ((U, U), (U, U))where U: PrimInt + Default,
Why this custom From<>? Useful for type coercion:
use quadtree_rs::{area::{Area, AreaBuilder}, point::Point};
let area: Area<_> = AreaBuilder::default()
.anchor(Point{x:1, y:2})
.dimensions((3,4))
.build().unwrap();
let (anchor, dims) = area.into();
assert_eq!(anchor, (1,2));
assert_eq!(dims, (3,4));
source§impl<U> PartialEq<Area<U>> for Area<U>where
U: PrimInt + Default + PartialOrd + PartialEq,
impl<U> PartialEq<Area<U>> for Area<U>where U: PrimInt + Default + PartialOrd + PartialEq,
impl<U> Copy for Area<U>where U: PrimInt + Default + PartialOrd + Copy,
impl<U> Eq for Area<U>where U: PrimInt + Default + PartialOrd + Eq,
impl<U> StructuralEq for Area<U>where U: PrimInt + Default + PartialOrd,
impl<U> StructuralPartialEq for Area<U>where U: PrimInt + Default + PartialOrd,
Auto Trait Implementations§
impl<U> RefUnwindSafe for Area<U>where U: RefUnwindSafe,
impl<U> Send for Area<U>where U: Send,
impl<U> Sync for Area<U>where U: Sync,
impl<U> Unpin for Area<U>where U: Unpin,
impl<U> UnwindSafe for Area<U>where U: UnwindSafe,
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