Struct euclid::Box3D[][src]

#[repr(C)]
pub struct Box3D<T, U> { pub min: Point3D<T, U>, pub max: Point3D<T, U>, }
Expand description

An axis aligned 3D box represented by its minimum and maximum coordinates.

Fields

min: Point3D<T, U>max: Point3D<T, U>

Implementations

impl<T, U> Box3D<T, U>[src]

pub const fn new(min: Point3D<T, U>, max: Point3D<T, U>) -> Self[src]

Constructor.

pub fn from_size(size: Size3D<T, U>) -> Self where
    T: Zero
[src]

Creates a Box3D of the given size, at offset zero.

impl<T, U> Box3D<T, U> where
    T: PartialOrd
[src]

pub fn is_negative(&self) -> bool[src]

Returns true if the box has a negative volume.

The common interpretation for a negative box is to consider it empty. It can be obtained by calculating the intersection of two boxes that do not intersect.

pub fn is_empty(&self) -> bool[src]

Returns true if the size is zero, negative or NaN.

pub fn intersects(&self, other: &Self) -> bool[src]

pub fn contains(&self, other: Point3D<T, U>) -> bool[src]

Returns true if this box3d contains the point. Points are considered in the box3d if they are on the front, left or top faces, but outside if they are on the back, right or bottom faces.

pub fn contains_box(&self, other: &Self) -> bool[src]

Returns true if this box3d contains the interior of the other box3d. Always returns true if other is empty, and always returns false if other is nonempty but this box3d is empty.

impl<T, U> Box3D<T, U> where
    T: Copy + PartialOrd
[src]

pub fn to_non_empty(&self) -> Option<Self>[src]

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

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

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

Computes the union of two boxes.

If either of the boxes is empty, the other one is returned.

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

#[must_use]
pub fn translate(&self, by: Vector3D<T, U>) -> Self
[src]

Returns the same box3d, translated by a vector.

impl<T, U> Box3D<T, U> where
    T: Copy + Sub<T, Output = T>, 
[src]

pub fn size(&self) -> Size3D<T, U>[src]

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

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

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

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

#[must_use]
pub fn inflate(&self, width: T, height: T, depth: T) -> Self
[src]

Inflates the box by the specified sizes on each side respectively.

impl<T, U> Box3D<T, U> where
    T: Copy + Zero + PartialOrd
[src]

pub fn from_points<I>(points: I) -> Self where
    I: IntoIterator,
    I::Item: Borrow<Point3D<T, U>>, 
[src]

Returns the smallest box containing all of the provided points.

impl<T, U> Box3D<T, U> where
    T: Copy + One + Add<Output = T> + Sub<Output = T> + Mul<Output = T>, 
[src]

pub fn lerp(&self, other: Self, t: T) -> Self[src]

Linearly interpolate between this box3d and another box3d.

impl<T, U> Box3D<T, U> where
    T: Copy + One + Add<Output = T> + Div<Output = T>, 
[src]

pub fn center(&self) -> Point3D<T, U>[src]

impl<T, U> Box3D<T, U> where
    T: Copy + Mul<T, Output = T> + Sub<T, Output = T>, 
[src]

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

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

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

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

impl<T, U> Box3D<T, U> where
    T: Zero
[src]

pub fn zero() -> Self[src]

Constructor, setting all sides to zero.

impl<T, U> Box3D<T, U> where
    T: Copy
[src]

pub fn x_range(&self) -> Range<T>[src]

pub fn y_range(&self) -> Range<T>[src]

pub fn z_range(&self) -> Range<T>[src]

pub fn to_untyped(&self) -> Box3D<T, UnknownUnit>[src]

Drop the units, preserving only the numeric value.

pub fn from_untyped(c: &Box3D<T, UnknownUnit>) -> Box3D<T, U>[src]

Tag a unitless value with units.

pub fn cast_unit<V>(&self) -> Box3D<T, V>[src]

Cast the unit

pub fn scale<S: Copy>(&self, x: S, y: S, z: S) -> Self where
    T: Mul<S, Output = T>, 
[src]

impl<T: NumCast + Copy, U> Box3D<T, U>[src]

pub fn cast<NewT: NumCast>(&self) -> Box3D<NewT, U>[src]

Cast from one numeric representation to another, preserving the units.

When casting from floating point to integer coordinates, the decimals are truncated as one would expect from a simple cast, but this behavior does not always make sense geometrically. Consider using round(), round_in or round_out() before casting.

pub fn try_cast<NewT: NumCast>(&self) -> Option<Box3D<NewT, U>>[src]

Fallible cast from one numeric representation to another, preserving the units.

When casting from floating point to integer coordinates, the decimals are truncated as one would expect from a simple cast, but this behavior does not always make sense geometrically. Consider using round(), round_in or round_out() before casting.

pub fn to_f32(&self) -> Box3D<f32, U>[src]

Cast into an f32 box3d.

pub fn to_f64(&self) -> Box3D<f64, U>[src]

Cast into an f64 box3d.

pub fn to_usize(&self) -> Box3D<usize, U>[src]

Cast into an usize box3d, truncating decimals if any.

When casting from floating point cuboids, it is worth considering whether to round(), round_in() or round_out() before the cast in order to obtain the desired conversion behavior.

pub fn to_u32(&self) -> Box3D<u32, U>[src]

Cast into an u32 box3d, truncating decimals if any.

When casting from floating point cuboids, it is worth considering whether to round(), round_in() or round_out() before the cast in order to obtain the desired conversion behavior.

pub fn to_i32(&self) -> Box3D<i32, U>[src]

Cast into an i32 box3d, truncating decimals if any.

When casting from floating point cuboids, it is worth considering whether to round(), round_in() or round_out() before the cast in order to obtain the desired conversion behavior.

pub fn to_i64(&self) -> Box3D<i64, U>[src]

Cast into an i64 box3d, truncating decimals if any.

When casting from floating point cuboids, it is worth considering whether to round(), round_in() or round_out() before the cast in order to obtain the desired conversion behavior.

impl<T: Float, U> Box3D<T, U>[src]

pub fn is_finite(self) -> bool[src]

Returns true if all members are finite.

impl<T, U> Box3D<T, U> where
    T: Round
[src]

#[must_use]
pub fn round(&self) -> Self
[src]

Return a box3d with edges rounded to integer coordinates, such that the returned box3d has the same set of pixel centers as the original one. Values equal to 0.5 round up. Suitable for most places where integral device coordinates are needed, but note that any translation should be applied first to avoid pixel rounding errors. Note that this is not rounding to nearest integer if the values are negative. They are always rounding as floor(n + 0.5).

impl<T, U> Box3D<T, U> where
    T: Floor + Ceil
[src]

#[must_use]
pub fn round_in(&self) -> Self
[src]

Return a box3d with faces/edges rounded to integer coordinates, such that the original box3d contains the resulting box3d.

#[must_use]
pub fn round_out(&self) -> Self
[src]

Return a box3d with faces/edges rounded to integer coordinates, such that the original box3d is contained in the resulting box3d.

Trait Implementations

impl<T: Clone, U> Clone for Box3D<T, U>[src]

fn clone(&self) -> Self[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<T: Debug, U> Debug for Box3D<T, U>[src]

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

Formats the value using the given formatter. Read more

impl<T: Default, U> Default for Box3D<T, U>[src]

fn default() -> Self[src]

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

impl<T: Copy + Div, U1, U2> Div<Scale<T, U1, U2>> for Box3D<T, U2>[src]

type Output = Box3D<T::Output, U1>

The resulting type after applying the / operator.

fn div(self, scale: Scale<T, U1, U2>) -> Self::Output[src]

Performs the / operation. Read more

impl<T: Copy + Div, U> Div<T> for Box3D<T, U>[src]

type Output = Box3D<T::Output, U>

The resulting type after applying the / operator.

fn div(self, scale: T) -> Self::Output[src]

Performs the / operation. Read more

impl<T: Copy + DivAssign, U> DivAssign<Scale<T, U, U>> for Box3D<T, U>[src]

fn div_assign(&mut self, scale: Scale<T, U, U>)[src]

Performs the /= operation. Read more

impl<T: Copy + DivAssign, U> DivAssign<T> for Box3D<T, U>[src]

fn div_assign(&mut self, scale: T)[src]

Performs the /= operation. Read more

impl<T, U> From<Size3D<T, U>> for Box3D<T, U> where
    T: Copy + Zero + PartialOrd
[src]

fn from(b: Size3D<T, U>) -> Self[src]

Performs the conversion.

impl<T: Hash, U> Hash for Box3D<T, U>[src]

fn hash<H: Hasher>(&self, h: &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<T: Copy + Mul, U1, U2> Mul<Scale<T, U1, U2>> for Box3D<T, U1>[src]

type Output = Box3D<T::Output, U2>

The resulting type after applying the * operator.

fn mul(self, scale: Scale<T, U1, U2>) -> Self::Output[src]

Performs the * operation. Read more

impl<T: Copy + Mul, U> Mul<T> for Box3D<T, U>[src]

type Output = Box3D<T::Output, U>

The resulting type after applying the * operator.

fn mul(self, scale: T) -> Self::Output[src]

Performs the * operation. Read more

impl<T: Copy + MulAssign, U> MulAssign<Scale<T, U, U>> for Box3D<T, U>[src]

fn mul_assign(&mut self, scale: Scale<T, U, U>)[src]

Performs the *= operation. Read more

impl<T: Copy + MulAssign, U> MulAssign<T> for Box3D<T, U>[src]

fn mul_assign(&mut self, scale: T)[src]

Performs the *= operation. Read more

impl<T: PartialEq, U> PartialEq<Box3D<T, U>> for Box3D<T, U>[src]

fn eq(&self, other: &Self) -> bool[src]

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<T: Copy, U> Copy for Box3D<T, U>[src]

impl<T: Eq, U> Eq for Box3D<T, U>[src]

Auto Trait Implementations

impl<T, U> RefUnwindSafe for Box3D<T, U> where
    T: RefUnwindSafe,
    U: RefUnwindSafe

impl<T, U> Send for Box3D<T, U> where
    T: Send,
    U: Send

impl<T, U> Sync for Box3D<T, U> where
    T: Sync,
    U: Sync

impl<T, U> Unpin for Box3D<T, U> where
    T: Unpin,
    U: Unpin

impl<T, U> UnwindSafe for Box3D<T, U> where
    T: UnwindSafe,
    U: 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.