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>
impl<S> Cuboid<S>
sourcepub fn from_x_y_z_w_h_d(x: S, y: S, z: S, w: S, h: S, d: S) -> Cuboid<S>
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).
sourcepub fn subdivision_ranges(&self) -> SubdivisionRanges<S>
pub fn subdivision_ranges(&self) -> SubdivisionRanges<S>
The six ranges used for the Cuboid
’s eight subdivisions.
sourcepub fn x_y_z_w_h_d(&self) -> (S, S, S, S, S, S)
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,
impl<S> Cuboid<S>where
S: Scalar,
sourcepub fn from_ranges(x: Range<S>, y: Range<S>, z: Range<S>) -> Cuboid<S>
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.
sourcepub fn absolute(&self) -> Cuboid<S>
pub fn absolute(&self) -> Cuboid<S>
Converts self
to an absolute Cuboid
so that the magnitude of each range is always
positive.
sourcepub fn contains_point(&self, _: [S; 3]) -> bool
pub fn contains_point(&self, _: [S; 3]) -> bool
Does the given cuboid contain the given point.
sourcepub fn stretch_to_point(self, _: [S; 3]) -> Cuboid<S>
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.
sourcepub fn overlap(self, other: Cuboid<S>) -> Option<Cuboid<S>>
pub fn overlap(self, other: Cuboid<S>) -> Option<Cuboid<S>>
The cuboid representing the area in which two cuboids overlap.
sourcepub fn max(self, other: Cuboid<S>) -> Cuboid<S>where
S: Float,
pub fn max(self, other: Cuboid<S>) -> Cuboid<S>where
S: Float,
The cuboid that encompass the two given cuboids.
sourcepub fn left_quad(&self) -> Quad<[S; 3]>
pub fn left_quad(&self) -> Quad<[S; 3]>
The quad for the face at the start of the range along the x axis.
sourcepub fn right_quad(&self) -> Quad<[S; 3]>
pub fn right_quad(&self) -> Quad<[S; 3]>
The quad for the face at the end of the range along the x axis.
sourcepub fn bottom_quad(&self) -> Quad<[S; 3]>
pub fn bottom_quad(&self) -> Quad<[S; 3]>
The quad for the face at the start of the range along the y axis.
sourcepub fn top_quad(&self) -> Quad<[S; 3]>
pub fn top_quad(&self) -> Quad<[S; 3]>
The quad for the face at the end of the range along the y axis.
sourcepub fn front_quad(&self) -> Quad<[S; 3]>
pub fn front_quad(&self) -> Quad<[S; 3]>
The quad for the face at the start of the range along the z axis.
sourcepub fn back_quad(&self) -> Quad<[S; 3]>
pub fn back_quad(&self) -> Quad<[S; 3]>
The quad for the face at the end of the range along the z axis.
sourcepub fn corners(&self) -> [[S; 3]; 8]
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
sourcepub fn corners_iter(&self) -> Corners<'_, S> ⓘ
pub fn corners_iter(&self) -> Corners<'_, S> ⓘ
The same as corners
but produces an iterator rather than a fixed-size array.
sourcepub fn faces(&self) -> [Quad<[S; 3]>; 6]
pub fn faces(&self) -> [Quad<[S; 3]>; 6]
The 6 faces of the of the cuboid in the order yielded by the Faces
iterator.
sourcepub fn faces_iter(&self) -> FaceQuads<'_, S> ⓘ
pub fn faces_iter(&self) -> FaceQuads<'_, S> ⓘ
An iterator yielding a quad for each face on the cuboid.
sourcepub fn triangles_iter(&self) -> Triangles<'_, S> ⓘ
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.
sourcepub fn w_h_d(&self) -> (S, S, S)
pub fn w_h_d(&self) -> (S, S, S)
The dimensions (width, height and depth) of the cuboid as a tuple.
sourcepub fn pad_left(self, pad: S) -> Cuboid<S>
pub fn pad_left(self, pad: S) -> Cuboid<S>
The cuboid with some padding applied to the left side.
sourcepub fn pad_right(self, pad: S) -> Cuboid<S>
pub fn pad_right(self, pad: S) -> Cuboid<S>
The cuboid with some padding applied to the right side.
sourcepub fn pad_bottom(self, pad: S) -> Cuboid<S>
pub fn pad_bottom(self, pad: S) -> Cuboid<S>
The cuboid with some padding applied to the bottom side.
sourcepub fn pad_top(self, pad: S) -> Cuboid<S>
pub fn pad_top(self, pad: S) -> Cuboid<S>
The cuboid with some padding applied to the top side.
sourcepub fn pad_front(self, pad: S) -> Cuboid<S>
pub fn pad_front(self, pad: S) -> Cuboid<S>
The cuboid with some padding applied to the front side.
source§impl Cuboid
impl Cuboid
sourcepub fn from_xyz_whd(p: Vec3, s: Vec3) -> Cuboid
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).
sourcepub fn stretch_to(self, p: Vec3) -> Cuboid
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>
impl Cuboid<f64>
sourcepub fn from_xyz_whd_f64(p: DVec3, s: DVec3) -> Cuboid<f64>
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).
sourcepub fn stretch_to(self, p: DVec3) -> Cuboid<f64>
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> PartialEq for Cuboid<S>where
S: PartialEq,
impl<S> PartialEq for Cuboid<S>where
S: PartialEq,
source§impl<S> PartialOrd for Cuboid<S>where
S: PartialOrd,
impl<S> PartialOrd for Cuboid<S>where
S: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl<S> Copy for Cuboid<S>where
S: Copy,
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
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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
source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
source§fn convert_into(self) -> U
fn convert_into(self) -> U
source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains the unclamped color. Read more