#[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>
impl<T: Unit> Box3<T>
sourcepub fn new(min: impl Into<Point3<T>>, max: impl Into<Point3<T>>) -> Self
pub fn new(min: impl Into<Point3<T>>, max: impl Into<Point3<T>>) -> Self
New 2D box from min/max coordinates.
sourcepub fn from_untyped(untyped: Box3<T::Scalar>) -> Box3<T>
pub fn from_untyped(untyped: Box3<T::Scalar>) -> Box3<T>
Bitcast an untyped instance to self.
sourcepub fn to_untyped(self) -> Box3<T::Scalar>
pub fn to_untyped(self) -> Box3<T::Scalar>
Bitcast self to an untyped instance.
sourcepub fn as_untyped(&self) -> &Box3<T::Scalar>
pub fn as_untyped(&self) -> &Box3<T::Scalar>
Reinterpret cast self as the untyped variant.
sourcepub fn as_untyped_mut(&mut self) -> &mut Box3<T::Scalar>
pub fn as_untyped_mut(&mut self) -> &mut Box3<T::Scalar>
Reinterpret cast self as the untyped variant.
sourcepub fn cast<T2>(self) -> Box3<T2>
pub fn cast<T2>(self) -> Box3<T2>
Cast to a different coordinate space with the same underlying scalar type.
sourcepub fn cast_ref<T2>(&self) -> &Box3<T2>
pub fn cast_ref<T2>(&self) -> &Box3<T2>
Cast to a different coordinate space with the same underlying scalar type.
sourcepub fn cast_mut<T2>(&mut self) -> &mut Box3<T2>
pub fn cast_mut<T2>(&mut self) -> &mut Box3<T2>
Cast to a different coordinate space with the same underlying scalar type.
sourcepub fn try_cast<T2>(self) -> Option<Box3<T2>>where
T2: Unit,
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.
sourcepub const fn from_tuple((min, max): (Point3<T>, Point3<T>)) -> Self
pub const fn from_tuple((min, max): (Point3<T>, Point3<T>)) -> Self
Instantiate from tuple.
source§impl<T> Box3<T>
impl<T> Box3<T>
sourcepub fn round(self) -> Self
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));
sourcepub fn round_in(self) -> Self
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));
sourcepub fn round_out(self) -> Self
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));
Trait Implementations§
source§impl<T: Unit> AbsDiffEq for Box3<T>
impl<T: Unit> AbsDiffEq for Box3<T>
§type Epsilon = <<T as Unit>::Scalar as AbsDiffEq>::Epsilon
type Epsilon = <<T as Unit>::Scalar as AbsDiffEq>::Epsilon
source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
source§fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
.source§impl<T: Unit> PartialEq<(Point3<T>, Point3<T>)> for Box3<T>
impl<T: Unit> PartialEq<(Point3<T>, Point3<T>)> for Box3<T>
source§impl<T: Unit> PartialEq for Box3<T>
impl<T: Unit> PartialEq for Box3<T>
source§impl<T: Unit> RelativeEq for Box3<T>where
T::Scalar: RelativeEq,
impl<T: Unit> RelativeEq for Box3<T>where
T::Scalar: RelativeEq,
source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool
source§fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool
RelativeEq::relative_eq
.source§impl<T: Unit> UlpsEq for Box3<T>
impl<T: Unit> UlpsEq for Box3<T>
impl<T: Unit> Copy for Box3<T>
impl<T> Eq for Box3<T>
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>
impl<T> RefUnwindSafe for Box3<T>
impl<T> Send for Box3<T>
impl<T> Sync for Box3<T>
impl<T> Unpin for Box3<T>
impl<T> UnwindSafe for Box3<T>
Blanket Implementations§
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
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
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.