Struct Aabb2

Source
pub struct Aabb2<F>
where F: OutputType,
{ /* private fields */ }
Expand description

A simple 2d axis aligned bounding box.

If min_max is None no data has been assigned.

Implementations§

Source§

impl<F> Aabb2<F>
where F: OutputType,

Source

pub fn new<I>(p1: &Point<I>, p2: &Point<I>) -> Aabb2<F>
where I: InputType,

Creates a new AABB with the limits defined by p1 & p2

Source

pub fn new_from_i32<I>(x1: i32, y1: i32, x2: i32, y2: i32) -> Aabb2<F>
where I: InputType,

Creates a new AABB with i32 coordinates

Source

pub fn update_point<I>(&mut self, point: &Point<I>)
where I: InputType,

Source

pub fn update_coordinate<I>(&mut self, x: i32, y: i32)
where I: InputType,

Source

pub fn update_vertex(&mut self, x: F, y: F)

Source

pub fn update_i64(&mut self, x: i64, y: i64)

Source

pub fn update_f64(&mut self, x: f64, y: f64)

Source

pub fn update_line<I>(&mut self, line: &Line<I>)
where I: InputType,

Source

pub fn get_high(&self) -> Option<[F; 2]>

Source

pub fn get_low(&self) -> Option<[F; 2]>

Source

pub fn grow_percent<I>(&mut self, percent: i32)
where I: InputType,

grows the aabb uniformly by some percent. method does nothing if not initialized

Source

pub fn contains_point<I>(&self, point: &Point<I>) -> Option<bool>
where I: InputType,

returns Some(true) if the aabb contains the point (inclusive) returns None if the aabb is uninitialized

 let p0 = Point::from([0,0]);
 let p1 = Point::from([1,1]);

 let aabb = Aabb2::<f32>::new(&p0,&p1);
 assert!(aabb.contains_point(&Point::from([1,1])).unwrap_or(false));
 assert!(!aabb.contains_point(&Point::from([2,1])).unwrap_or(true));
Source

pub fn contains_line<I>(&self, line: &Line<I>) -> Option<bool>
where I: InputType,

returns Some(true) if the aabb contains the line (inclusive) returns None if the aabb is uninitialized

let p0 = Point::from([0,0]);
let p1 = Point::from([10,10]);

let aabb = Aabb2::<f32>::new(&p0,&p1);
assert!( aabb.contains_line(&Line::from([1,1,10,10])).unwrap_or(false));
assert!(!aabb.contains_line(&Line::from([1,-1,10,10])).unwrap_or(true));

Trait Implementations§

Source§

impl<F> Clone for Aabb2<F>
where F: Clone + OutputType,

Source§

fn clone(&self) -> Aabb2<F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F> Debug for Aabb2<F>
where F: Debug + OutputType,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<F> Default for Aabb2<F>
where F: OutputType,

Source§

fn default() -> Aabb2<F>

Returns the “default value” for a type. Read more
Source§

impl<F> PartialEq for Aabb2<F>
where F: PartialEq + OutputType,

Source§

fn eq(&self, other: &Aabb2<F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F> Eq for Aabb2<F>
where F: Eq + OutputType,

Source§

impl<F> StructuralPartialEq for Aabb2<F>
where F: OutputType,

Auto Trait Implementations§

§

impl<F> Freeze for Aabb2<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for Aabb2<F>
where F: RefUnwindSafe,

§

impl<F> Send for Aabb2<F>
where F: Send,

§

impl<F> Sync for Aabb2<F>

§

impl<F> Unpin for Aabb2<F>

§

impl<F> UnwindSafe for Aabb2<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.