Struct nannou::prelude::Cuboid

source ·
pub struct Cuboid<S = f32> {
    pub x: Range<S>,
    pub y: Range<S>,
    pub z: Range<S>,
}
Expand description

A light-weight Cuboid type with many helper and utility methods.

The cuboid is also known as a “rectangular prism”.

Cuboid is implemented similarly to geom::Rect but with 3 axes instead of 2.

Fields§

§x: Range<S>

The start and end along the x axis.

§y: Range<S>

The start and end along the y axis.

§z: Range<S>

The start and end along the z axis.

Implementations§

source§

impl<S> Cuboid<S>
where S: Float + Scalar,

source

pub fn from_x_y_z_w_h_d(x: S, y: S, z: S, w: S, h: S, d: S) -> Cuboid<S>

Construct a Rect from a given centre point (x, y, z) and dimensions (width, height, depth).

source

pub fn x(&self) -> S

The position in the middle of the x range.

source

pub fn y(&self) -> S

The position in the middle of the y range.

source

pub fn z(&self) -> S

The position in the middle of the z range.

source

pub fn x_y_z(&self) -> (S, S, S)

The centered x, y and z coordinates as a tuple.

source

pub fn subdivision_ranges(&self) -> SubdivisionRanges<S>

The six ranges used for the Cuboid’s eight subdivisions.

source

pub fn x_y_z_w_h_d(&self) -> (S, S, S, S, S, S)

The position and dimensions of the cuboid.

source§

impl<S> Cuboid<S>
where S: Scalar,

source

pub fn from_ranges(x: Range<S>, y: Range<S>, z: Range<S>) -> Cuboid<S>

Construct a cuboid from its x, y and z ranges.

source

pub fn absolute(&self) -> Cuboid<S>

Converts self to an absolute Cuboid so that the magnitude of each range is always positive.

source

pub fn shift_x(self, x: S) -> Cuboid<S>

Shift the cuboid along the x axis.

source

pub fn shift_y(self, y: S) -> Cuboid<S>

Shift the cuboid along the y axis.

source

pub fn shift_z(self, z: S) -> Cuboid<S>

Shift the cuboid along the z axis.

source

pub fn shift_by(self, _: [S; 3]) -> Cuboid<S>

Shift the cuboid by the given vector.

source

pub fn contains_point(&self, _: [S; 3]) -> bool

Does the given cuboid contain the given point.

source

pub fn stretch_to_point(self, _: [S; 3]) -> Cuboid<S>

Stretches the closest side(s) to the given point if the point lies outside of the Cuboid area.

source

pub fn overlap(self, other: Cuboid<S>) -> Option<Cuboid<S>>

The cuboid representing the area in which two cuboids overlap.

source

pub fn max(self, other: Cuboid<S>) -> Cuboid<S>
where S: Float,

The cuboid that encompass the two given cuboids.

source

pub fn left(&self) -> S

The start of the range along the x axis.

source

pub fn right(&self) -> S

The end of the range along the x axis.

source

pub fn bottom(&self) -> S

The start of the range along the y axis.

source

pub fn top(&self) -> S

The end of the range along the y axis.

source

pub fn front(&self) -> S

The start of the range along the z axis.

source

pub fn back(&self) -> S

The end of the range along the z axis.

source

pub fn left_quad(&self) -> Quad<[S; 3]>

The quad for the face at the start of the range along the x axis.

source

pub fn right_quad(&self) -> Quad<[S; 3]>

The quad for the face at the end of the range along the x axis.

source

pub fn bottom_quad(&self) -> Quad<[S; 3]>

The quad for the face at the start of the range along the y axis.

source

pub fn top_quad(&self) -> Quad<[S; 3]>

The quad for the face at the end of the range along the y axis.

source

pub fn front_quad(&self) -> Quad<[S; 3]>

The quad for the face at the start of the range along the z axis.

source

pub fn back_quad(&self) -> Quad<[S; 3]>

The quad for the face at the end of the range along the z axis.

source

pub fn face_quad(&self, face: Face) -> Quad<[S; 3]>

The quad for the given face.

source

pub fn corners(&self) -> [[S; 3]; 8]

The 8 corners of the cuboid in the following order:

y
| z
|/
0---x

  6---7
 /|  /|
2---3 |
| 4-|-5
|/  |/
0---1
source

pub fn corners_iter(&self) -> Corners<'_, S>

The same as corners but produces an iterator rather than a fixed-size array.

source

pub fn faces(&self) -> [Quad<[S; 3]>; 6]

The 6 faces of the of the cuboid in the order yielded by the Faces iterator.

source

pub fn faces_iter(&self) -> FaceQuads<'_, S>

An iterator yielding a quad for each face on the cuboid.

source

pub fn triangles_iter(&self) -> Triangles<'_, S>

Produce an iterator yielding every triangle in the cuboid (two for each face).

Uses the faces_iter method internally.

source

pub fn w(&self) -> S

The length of the cuboid along the x axis (aka width or w for short).

source

pub fn h(&self) -> S

The length of the cuboid along the y axis (aka height or h for short).

source

pub fn d(&self) -> S

The length of the cuboid along the z axis (aka depth or d for short).

source

pub fn w_h_d(&self) -> (S, S, S)

The dimensions (width, height and depth) of the cuboid as a tuple.

source

pub fn volume(&self) -> S

The total volume of the cuboid.

source

pub fn pad_left(self, pad: S) -> Cuboid<S>

The cuboid with some padding applied to the left side.

source

pub fn pad_right(self, pad: S) -> Cuboid<S>

The cuboid with some padding applied to the right side.

source

pub fn pad_bottom(self, pad: S) -> Cuboid<S>

The cuboid with some padding applied to the bottom side.

source

pub fn pad_top(self, pad: S) -> Cuboid<S>

The cuboid with some padding applied to the top side.

source

pub fn pad_front(self, pad: S) -> Cuboid<S>

The cuboid with some padding applied to the front side.

source

pub fn pad_back(self, pad: S) -> Cuboid<S>

The cuboid with some padding applied to the back side.

source

pub fn pad(self, pad: S) -> Cuboid<S>

The cuboid with some padding amount applied to each side.

source§

impl Cuboid

source

pub fn from_xyz_whd(p: Vec3, s: Vec3) -> Cuboid

Construct a Rect from a given centre point (x, y, z) and dimensions (width, height, depth).

source

pub fn xyz(&self) -> Vec3

The xyz position in the middle of the bounds.

source

pub fn whd(&self) -> Vec3

The dimensions (width, height and depth) of the cuboid as a vector.

source

pub fn xyz_whd(&self) -> (Vec3, Vec3)

The position and dimensions of the cuboid.

source

pub fn shift(self, v: Vec3) -> Cuboid

Shift the cuboid by the given vector.

source

pub fn contains(&self, p: Vec3) -> bool

Does the given cuboid contain the given point.

source

pub fn stretch_to(self, p: Vec3) -> Cuboid

Stretches the closest side(s) to the given point if the point lies outside of the Cuboid area.

source§

impl Cuboid<f64>

source

pub fn from_xyz_whd_f64(p: DVec3, s: DVec3) -> Cuboid<f64>

Construct a Rect from a given centre point (x, y, z) and dimensions (width, height, depth).

source

pub fn xyz(&self) -> DVec3

The xyz position in the middle of the bounds.

source

pub fn whd(&self) -> DVec3

The dimensions (width, height and depth) of the cuboid as a vector.

source

pub fn xyz_whd(&self) -> (DVec3, DVec3)

The position and dimensions of the cuboid.

source

pub fn shift(self, v: DVec3) -> Cuboid<f64>

Shift the cuboid by the given vector.

source

pub fn contains(&self, p: DVec3) -> bool

Does the given cuboid contain the given point.

source

pub fn stretch_to(self, p: DVec3) -> Cuboid<f64>

Stretches the closest side(s) to the given point if the point lies outside of the Cuboid area.

Trait Implementations§

source§

impl<S> Clone for Cuboid<S>
where S: Clone,

source§

fn clone(&self) -> Cuboid<S>

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<S> Debug for Cuboid<S>
where S: Debug,

source§

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

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

impl<S> PartialEq for Cuboid<S>
where S: PartialEq,

source§

fn eq(&self, other: &Cuboid<S>) -> 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<S> PartialOrd for Cuboid<S>
where S: PartialOrd,

source§

fn partial_cmp(&self, other: &Cuboid<S>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<S> Copy for Cuboid<S>
where S: Copy,

source§

impl<S> StructuralPartialEq for Cuboid<S>

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Cuboid<S>
where S: RefUnwindSafe,

§

impl<S> Send for Cuboid<S>
where S: Send,

§

impl<S> Sync for Cuboid<S>
where S: Sync,

§

impl<S> Unpin for Cuboid<S>
where S: Unpin,

§

impl<S> UnwindSafe for Cuboid<S>
where S: UnwindSafe,

Blanket Implementations§

source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Component + Float, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
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, U> ConvertInto<U> for T
where U: ConvertFrom<T>,

source§

fn convert_into(self) -> U

Convert into T with values clamped to the color defined bounds Read more
source§

fn convert_unclamped_into(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
source§

fn try_convert_into(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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

§

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