Struct vek::geom::repr_c::Rect3[][src]

pub struct Rect3<P, E> {
    pub x: P,
    pub y: P,
    pub z: P,
    pub w: E,
    pub h: E,
    pub d: E,
}
Expand description

A Rect extended to 3D.

This would have been named Box, but it was “taken” by the standard library already.

You should probably use Aabb because it is less confusing. See also Rect for a short discussion on the topic.

Fields

x: P
Expand description

X position of the bottom-left-near corner.

y: P
Expand description

Y position of the bottom-left-near corner.

z: P
Expand description

Z position of the bottom-left-near corner.

w: E
Expand description

Width.

h: E
Expand description

Height, with Y axis going upwards.

d: E
Expand description

Depth, with Z axis going forwards.

Implementations

impl<P, E> Rect3<P, E>[src]

pub fn new(x: P, y: P, z: P, w: E, h: E, d: E) -> Self[src]

Creates a new rectangle from position elements and extent elements.

pub fn position(self) -> Vec3<P>[src]

Gets this rectangle’s position.

pub fn extent(self) -> Extent3<E>[src]

Gets this rectangle’s extent (size).

pub fn position_extent(self) -> (Vec3<P>, Extent3<E>)[src]

Gets this rectangle’s position and extent (size).

pub fn map<DP, DE, PF, EF>(self, pf: PF, ef: EF) -> Rect3<DP, DE> where
    PF: FnMut(P) -> DP,
    EF: FnMut(E) -> DE, 
[src]

Returns this rectangle, converted with the given closures (one for position elements, the other for extent elements).

pub fn as_<DP, DE>(self) -> Rect3<DP, DE> where
    P: AsPrimitive<DP>,
    DP: 'static + Copy,
    E: AsPrimitive<DE>,
    DE: 'static + Copy
[src]

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

impl<T> Rect3<T, T> where
    T: Copy + Add<T, Output = T>, 
[src]

pub fn into_aabb(self) -> Aabb<T>[src]

Converts this into the matching axis-aligned bounding shape representation.

pub fn contains_point(self, p: Vec3<T>) -> bool where
    T: PartialOrd
[src]

Does this rectangle contain the given point ?

pub fn contains_rect3(self, other: Self) -> bool where
    T: PartialOrd
[src]

Does this rectangle fully contain the given one ?

pub fn collides_with_rect3(self, other: Self) -> bool where
    T: PartialOrd
[src]

Does this rectangle collide with another ?

pub fn center(self) -> Vec3<T> where
    T: One + Div<T, Output = T>, 
[src]

Gets this rectangle’s center.

impl<T> Rect3<T, T> where
    T: Copy + PartialOrd + Sub<T, Output = T> + Add<T, Output = T>, 
[src]

pub fn expanded_to_contain_point(self, p: Vec3<T>) -> Self where
    T: PartialOrd
[src]

Returns this shape so that it contains the given point.

pub fn expand_to_contain_point(&mut self, p: Vec3<T>) where
    T: PartialOrd
[src]

Expands this shape so that it contains the given point.

pub fn union(self, other: Self) -> Self[src]

Gets the smallest rectangle that contains both this one and another.

pub fn intersection(self, other: Self) -> Self[src]

Gets the largest rectangle contained by both this one and another.

pub fn expand_to_contain(&mut self, other: Self)[src]

Sets this rectangle to the union of itself with another.

pub fn intersect(&mut self, other: Self)[src]

Sets this rectangle to the intersection of itself with another.

pub fn collision_vector_with_rect3(self, other: Self) -> Vec3<T> where
    T: One + Div<T, Output = T>, 
[src]

Gets a vector that tells how much self penetrates other.

pub fn split_at_x(self, sp: T) -> [Self; 2][src]

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.

pub fn split_at_y(self, sp: T) -> [Self; 2][src]

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.

pub fn split_at_z(self, sp: T) -> [Self; 2][src]

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

Panics

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

Trait Implementations

impl<P: Clone, E: Clone> Clone for Rect3<P, E>[src]

fn clone(&self) -> Rect3<P, E>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<P: Debug, E: Debug> Debug for Rect3<P, E>[src]

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

Formats the value using the given formatter. Read more

impl<P: Default, E: Default> Default for Rect3<P, E>[src]

fn default() -> Rect3<P, E>[src]

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

impl<'de, P, E> Deserialize<'de> for Rect3<P, E> where
    P: Deserialize<'de>,
    E: Deserialize<'de>, 
[src]

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

Deserialize this value from the given Serde deserializer. Read more

impl<P, E> From<(Vec3<P>, Extent3<E>)> for Rect3<P, E>[src]

fn from(t: (Vec3<P>, Extent3<E>)) -> Self[src]

Performs the conversion.

impl<T> From<Aabb<T>> for Rect3<T, T> where
    T: Copy + Sub<T, Output = T>, 
[src]

fn from(aab: Aabb<T>) -> Self[src]

Performs the conversion.

impl<T> From<Rect3<T, T>> for Aabb<T> where
    T: Copy + Add<T, Output = T>, 
[src]

fn from(rect: Rect3<T, T>) -> Self[src]

Performs the conversion.

impl<P: Hash, E: Hash> Hash for Rect3<P, E>[src]

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

Feeds this value into the given Hasher. Read more

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

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

impl<P: PartialEq, E: PartialEq> PartialEq<Rect3<P, E>> for Rect3<P, E>[src]

fn eq(&self, other: &Rect3<P, E>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Rect3<P, E>) -> bool[src]

This method tests for !=.

impl<P, E> Serialize for Rect3<P, E> where
    P: Serialize,
    E: Serialize
[src]

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

Serialize this value into the given Serde serializer. Read more

impl<P: Copy, E: Copy> Copy for Rect3<P, E>[src]

impl<P: Eq, E: Eq> Eq for Rect3<P, E>[src]

impl<P, E> StructuralEq for Rect3<P, E>[src]

impl<P, E> StructuralPartialEq for Rect3<P, E>[src]

Auto Trait Implementations

impl<P, E> RefUnwindSafe for Rect3<P, E> where
    E: RefUnwindSafe,
    P: RefUnwindSafe

impl<P, E> Send for Rect3<P, E> where
    E: Send,
    P: Send

impl<P, E> Sync for Rect3<P, E> where
    E: Sync,
    P: Sync

impl<P, E> Unpin for Rect3<P, E> where
    E: Unpin,
    P: Unpin

impl<P, E> UnwindSafe for Rect3<P, E> where
    E: UnwindSafe,
    P: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]