Struct vek::geom::repr_c::Aabr

source ·
pub struct Aabr<T> {
    pub min: Vec2<T>,
    pub max: Vec2<T>,
}
Expand description

Axis-aligned Bounding Rectangle (2D), represented by min and max points.

N.B: You are responsible for ensuring that all respective elements of min are indeed less than or equal to those of max. The is_valid(), make_valid() and made_valid() methods are designed to help you with this.

Fields§

§min: Vec2<T>

Minimum coordinates of bounds.

§max: Vec2<T>

Maximum coordinates of bounds.

Implementations§

source§

impl<T> Aabr<T>

source

pub fn is_valid(&self) -> boolwhere T: PartialOrd,

Is this bounding shape valid ? True only if all elements of self.min are less than or equal to those of self.max.

source

pub fn make_valid(&mut self)where T: PartialOrd,

Makes this bounding shape valid by swapping elements of self.min with self.max as needed.

source

pub fn made_valid(self) -> Selfwhere T: PartialOrd,

Returns this bounding shape made valid by swapping elements of self.min with self.max as needed.

source

pub fn new_empty(p: Vec2<T>) -> Selfwhere T: Copy,

Creates a new bounding shape from a single point.

source

pub fn into_rect(self) -> Rect<T, T>where T: Copy + Sub<T, Output = T>,

Converts this bounding shape to the matching rectangle representation.

source

pub fn center(self) -> Vec2<T>where T: Copy + One + Add<T, Output = T> + Div<T, Output = T>,

Gets this bounding shape’s center.

source

pub fn size(self) -> Extent2<T>where T: Copy + Sub<T, Output = T>,

Gets this bounding shape’s total size.

source

pub fn half_size(self) -> Extent2<T>where T: Copy + Sub<T, Output = T> + One + Div<T, Output = T> + Add<T, Output = T>,

Gets this bounding shape’s half size.

source

pub fn union(self, other: Self) -> Selfwhere T: PartialOrd,

Gets the smallest bounding shape that contains both this one and another.

source

pub fn intersection(self, other: Self) -> Selfwhere T: PartialOrd,

Gets the largest bounding shape contained by both this one and another.

source

pub fn expand_to_contain(&mut self, other: Self)where T: Copy + PartialOrd,

Sets this bounding shape to the union of itself with another.

source

pub fn intersect(&mut self, other: Self)where T: Copy + PartialOrd,

Sets this bounding shape to the intersection of itself with another.

source

pub fn expanded_to_contain_point(self, p: Vec2<T>) -> Selfwhere T: Copy + PartialOrd,

Gets a copy of this shape so that it contains the given point.

source

pub fn expand_to_contain_point(&mut self, p: Vec2<T>)where T: Copy + PartialOrd,

Expands this shape so that it contains the given point.

source

pub fn contains_point(self, p: Vec2<T>) -> boolwhere T: PartialOrd,

Does this bounding shape contain the given point ?

source

pub fn contains_aabr(self, other: Self) -> boolwhere T: PartialOrd,

Does this bounding shape fully contain another ?

source

pub fn collides_with_aabr(self, other: Self) -> boolwhere T: PartialOrd,

Does this bounding shape collide with another ?

source

pub fn collision_vector_with_aabr(self, other: Self) -> Vec2<T>where T: Copy + PartialOrd + Sub<T, Output = T> + One + Add<T, Output = T> + Div<T, Output = T>,

Gets a vector that tells how much self penetrates other.

source

pub fn projected_point(self, p: Vec2<T>) -> Vec2<T>where T: Clamp,

Project the given point into the bounding shape (equivalent to ‘snapping’ the point to the closest point in the bounding shape).

source

pub fn distance_to_point(self, p: Vec2<T>) -> Twhere T: Clamp + Real + Add<T, Output = T> + RelativeEq,

Get the smallest distance between the bounding shape and a point.

source

pub fn split_at_x(self, sp: T) -> [Self; 2]where T: Copy + PartialOrd,

Splits this shape in two, by a straight plane along the x axis. The returned tuple is (low, high).

Panics

sp is assumed to be a position along the x axis that is within this shape’s bounds.

source

pub fn split_at_y(self, sp: T) -> [Self; 2]where T: Copy + PartialOrd,

Splits this shape in two, by a straight plane along the y axis. The returned tuple is (low, high).

Panics

sp is assumed to be a position along the y axis that is within this shape’s bounds.

source

pub fn map<D, F>(self, f: F) -> Aabr<D>where F: FnMut(T) -> D,

Returns this bounding shape, converted element-wise using the given closure.

source

pub fn as_<D>(self) -> Aabr<D>where T: AsPrimitive<D>, D: 'static + Copy,

Converts this rectangle to a rectangle of another type, using the as conversion.

Trait Implementations§

source§

impl<T: Clone> Clone for Aabr<T>

source§

fn clone(&self) -> Aabr<T>

Returns a copy 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<T: Debug> Debug for Aabr<T>

source§

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

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

impl<T: Default> Default for Aabr<T>

source§

fn default() -> Aabr<T>

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

impl<'de, T> Deserialize<'de> for Aabr<T>where T: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> From<Aabb<T>> for Aabr<T>

source§

fn from(aabb: Aabb<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Aabr<T>> for Rect<T, T>where T: Copy + Sub<T, Output = T>,

source§

fn from(aab: Aabr<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Rect<T, T>> for Aabr<T>where T: Copy + Add<T, Output = T>,

source§

fn from(rect: Rect<T, T>) -> Self

Converts to this type from the input type.
source§

impl<T: Hash> Hash for Aabr<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: PartialEq> PartialEq<Aabr<T>> for Aabr<T>

source§

fn eq(&self, other: &Aabr<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for Aabr<T>where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Copy> Copy for Aabr<T>

source§

impl<T: Eq> Eq for Aabr<T>

source§

impl<T> StructuralEq for Aabr<T>

source§

impl<T> StructuralPartialEq for Aabr<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Aabr<T>where T: RefUnwindSafe,

§

impl<T> Send for Aabr<T>where T: Send,

§

impl<T> Sync for Aabr<T>where T: Sync,

§

impl<T> Unpin for Aabr<T>where T: Unpin,

§

impl<T> UnwindSafe for Aabr<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,