Struct glamour::Box3

source ·
#[repr(C)]
pub struct Box3<T: Unit = f32> { pub min: Point3<T>, pub max: Point3<T>, }
Expand description

3D axis-aligned box.

Fields§

§min: Point3<T>

Lower bound of the box.

§max: Point3<T>

Upper bound of the box.

Implementations§

source§

impl<T: Unit> Box3<T>

source

pub const ZERO: Self = _

Zero-sized box.

source

pub fn new(min: impl Into<Point3<T>>, max: impl Into<Point3<T>>) -> Self

New 2D box from min/max coordinates.

source

pub fn from_untyped(untyped: Box3<T::Scalar>) -> Box3<T>

Bitcast an untyped instance to self.

source

pub fn to_untyped(self) -> Box3<T::Scalar>

Bitcast self to an untyped instance.

source

pub fn as_untyped(&self) -> &Box3<T::Scalar>

Reinterpret cast self as the untyped variant.

source

pub fn as_untyped_mut(&mut self) -> &mut Box3<T::Scalar>

Reinterpret cast self as the untyped variant.

source

pub fn cast<T2>(self) -> Box3<T2>
where T2: Unit<Scalar = T::Scalar>,

Cast to a different coordinate space with the same underlying scalar type.

source

pub fn cast_ref<T2>(&self) -> &Box3<T2>
where T2: Unit<Scalar = T::Scalar>,

Cast to a different coordinate space with the same underlying scalar type.

source

pub fn cast_mut<T2>(&mut self) -> &mut Box3<T2>
where T2: Unit<Scalar = T::Scalar>,

Cast to a different coordinate space with the same underlying scalar type.

source

pub fn try_cast<T2>(self) -> Option<Box3<T2>>
where T2: Unit,

Cast to a different coordinate space with scalar type conversion. Returns None if any component could not be converted to the target scalar type.

source

pub const fn from_tuple((min, max): (Point3<T>, Point3<T>)) -> Self

Instantiate from tuple.

source

pub const fn to_tuple(self) -> (Point3<T>, Point3<T>)

Convert to tuple.

source§

impl<T> Box3<T>
where T: Unit, T::Scalar: FloatScalar,

source

pub fn round(self) -> Self

Round coordinates to the nearest integer.

Note: This function makes no attempt to avoid creating “degenerate” boxes, where min >= max.

§Example
let b = Box3::<f32>::new((0.3, 0.3, 0.3), (2.7, 2.7, 2.7));
let rounded = b.round();
assert_eq!(rounded.min, (0.0, 0.0, 0.0));
assert_eq!(rounded.max, (3.0, 3.0, 3.0));
source

pub fn round_in(self) -> Self

Round towards from the center of the box.

Note: This function makes no attempt to avoid creating “degenerate” boxes, where min >= max.

§Example
let b = Box3::<f32>::new((0.3, 0.3, 0.3), (2.7, 2.7, 2.7));
let rounded = b.round_in();
assert_eq!(rounded.min, (1.0, 1.0, 1.0));
assert_eq!(rounded.max, (2.0, 2.0, 2.0));
source

pub fn round_out(self) -> Self

Round away from the center of the box.

Note: This function can only create “degenerate” boxes (where min >= max) if the box was already degenerate.

§Example
let b = Box3::<f32>::new((0.7, 0.7, 0.7), (1.4, 1.4, 1.4));
let rounded = b.round_out();
assert_eq!(rounded.min, (0.0, 0.0, 0.0));
assert_eq!(rounded.max, (2.0, 2.0, 2.0));
source

pub fn lerp(self, other: Self, t: T::Scalar) -> Self

Linear interpolation between boxes.

Trait Implementations§

source§

impl<T: Unit> AbsDiffEq for Box3<T>

§

type Epsilon = <<T as Unit>::Scalar as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
source§

fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
source§

impl<T: Unit> Clone for Box3<T>

source§

fn clone(&self) -> Self

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: Unit> Debug for Box3<T>

source§

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

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

impl<T: Unit> Default for Box3<T>

source§

fn default() -> Self

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

impl<T: Unit> From<(Point3<T>, Point3<T>)> for Box3<T>

source§

fn from(tuple: (Point3<T>, Point3<T>)) -> Box3<T>

Converts to this type from the input type.
source§

impl<T: Unit> From<Box3<T>> for (Point3<T>, Point3<T>)

source§

fn from(value: Box3<T>) -> (Point3<T>, Point3<T>)

Converts to this type from the input type.
source§

impl<T> Hash for Box3<T>
where T: Unit, T::Scalar: Hash,

source§

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

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: Unit> PartialEq<(Point3<T>, Point3<T>)> for Box3<T>

source§

fn eq(&self, (min, max): &(Point3<T>, Point3<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: Unit> PartialEq for Box3<T>

source§

fn eq(&self, other: &Self) -> 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: Unit> RelativeEq for Box3<T>
where T::Scalar: RelativeEq,

source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of RelativeEq::relative_eq.
source§

impl<T: Unit> UlpsEq for Box3<T>
where T::Scalar: UlpsEq,

source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.
source§

impl<T: Unit> Zeroable for Box3<T>

SAFETY: All members are Pod, and we are #[repr(C)].

source§

fn zeroed() -> Self

source§

impl<T: Unit> Copy for Box3<T>

source§

impl<T> Eq for Box3<T>
where T: Unit, T::Scalar: Eq,

source§

impl<T: Unit> Pod for Box3<T>

SAFETY: All members are Pod, and we are #[repr(C)].

Auto Trait Implementations§

§

impl<T> Freeze for Box3<T>
where <T as Unit>::Scalar: Freeze,

§

impl<T> RefUnwindSafe for Box3<T>
where <T as Unit>::Scalar: RefUnwindSafe,

§

impl<T> Send for Box3<T>

§

impl<T> Sync for Box3<T>

§

impl<T> Unpin for Box3<T>
where <T as Unit>::Scalar: Unpin,

§

impl<T> UnwindSafe for Box3<T>
where <T as Unit>::Scalar: UnwindSafe,

Blanket Implementations§

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> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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.

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

impl<T> AnyBitPattern for T
where T: Pod,

source§

impl<T> NoUninit for T
where T: Pod,

source§

impl<T> PodValue for T
where T: Copy + Debug + Default + PartialEq + Pod + Send + Sync + Serializable + 'static,

source§

impl<T> Serializable for T