Struct ultraviolet::int::UVec3
source · [−]Expand description
A set of three coordinates which may be interpreted as a point or vector in 3d space, or as a homogeneous 2d vector or point.
Generally this distinction between a point and vector is more of a pain than it is worth to distinguish on a type level, however when converting to and from homogeneous coordinates it is quite important.
Fields
x: u32
y: u32
z: u32
Implementations
sourceimpl UVec3
impl UVec3
pub const fn new(x: u32, y: u32, z: u32) -> Self
pub fn broadcast(val: u32) -> Self
pub fn unit_x() -> Self
pub fn unit_y() -> Self
pub fn unit_z() -> Self
pub fn cross(&self, other: UVec3) -> Self
sourcepub fn into_homogeneous_point(self) -> UVec4
pub fn into_homogeneous_point(self) -> UVec4
Create a homogeneous 3d point from this vector interpreted as a point, meaning the homogeneous component will start with a value of 1.
sourcepub fn into_homogeneous_vector(self) -> UVec4
pub fn into_homogeneous_vector(self) -> UVec4
Create a homogeneous 3d vector from this vector, meaning the homogeneous component will always have a value of 0.
sourcepub fn from_homogeneous_point(v: UVec4) -> Self
pub fn from_homogeneous_point(v: UVec4) -> Self
Create a 3d point from a homogeneous 3d point, performing division by the homogeneous component. This should not be used for homogeneous 3d vectors, which will have 0 as their homogeneous component.
sourcepub fn from_homogeneous_vector(v: UVec4) -> Self
pub fn from_homogeneous_vector(v: UVec4) -> Self
Create a 3d vector from homogeneous 2d vector, which simply discards the homogeneous component.
pub fn dot(&self, other: UVec3) -> u32
pub fn reflect(&mut self, normal: UVec3)
pub fn reflected(&self, normal: UVec3) -> Self
pub fn mag(&self) -> u32
pub fn mag_sq(&self) -> u32
pub fn mul_add(&self, mul: UVec3, add: UVec3) -> Self
pub fn clamp(&mut self, min: Self, max: Self)
pub fn clamped(self, min: Self, max: Self) -> Self
pub fn map<F>(&self, f: F) -> Self where
F: FnMut(u32) -> u32,
pub fn apply<F>(&mut self, f: F) where
F: FnMut(u32) -> u32,
pub fn max_by_component(self, other: Self) -> Self
pub fn min_by_component(self, other: Self) -> Self
pub fn component_max(&self) -> u32
pub fn component_min(&self) -> u32
pub fn zero() -> Self
pub fn one() -> Self
pub fn xy(&self) -> UVec2
pub fn xyzw(&self) -> UVec4
pub fn layout() -> Layout
pub fn as_slice(&self) -> &[u32]
pub fn as_array(&self) -> [u32; 3]
pub fn as_byte_slice(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_mut_slice(&mut self) -> &mut [u32]
pub fn as_mut_byte_slice(&mut self) -> &mut [u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
sourcepub fn as_ptr(&self) -> *const u32
pub fn as_ptr(&self) -> *const u32
Returns a constant unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.
Safety
It is up to the caller to correctly use this pointer and its bounds.
sourcepub fn as_mut_ptr(&mut self) -> *mut u32
pub fn as_mut_ptr(&mut self) -> *mut u32
Returns a mutable unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.
Safety
It is up to the caller to correctly use this pointer and its bounds.
Trait Implementations
sourceimpl AddAssign<UVec3> for UVec3
impl AddAssign<UVec3> for UVec3
sourcefn add_assign(&mut self, rhs: UVec3)
fn add_assign(&mut self, rhs: UVec3)
Performs the +=
operation. Read more
sourceimpl<'de> Deserialize<'de> for UVec3
impl<'de> Deserialize<'de> for UVec3
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl DivAssign<UVec3> for UVec3
impl DivAssign<UVec3> for UVec3
sourcefn div_assign(&mut self, rhs: UVec3)
fn div_assign(&mut self, rhs: UVec3)
Performs the /=
operation. Read more
sourceimpl DivAssign<u32> for UVec3
impl DivAssign<u32> for UVec3
sourcefn div_assign(&mut self, rhs: u32)
fn div_assign(&mut self, rhs: u32)
Performs the /=
operation. Read more
sourceimpl MulAssign<UVec3> for UVec3
impl MulAssign<UVec3> for UVec3
sourcefn mul_assign(&mut self, rhs: UVec3)
fn mul_assign(&mut self, rhs: UVec3)
Performs the *=
operation. Read more
sourceimpl MulAssign<u32> for UVec3
impl MulAssign<u32> for UVec3
sourcefn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
Performs the *=
operation. Read more
sourceimpl SubAssign<UVec3> for UVec3
impl SubAssign<UVec3> for UVec3
sourcefn sub_assign(&mut self, rhs: UVec3)
fn sub_assign(&mut self, rhs: UVec3)
Performs the -=
operation. Read more
sourceimpl TryFrom<DVec3> for UVec3
impl TryFrom<DVec3> for UVec3
sourcefn try_from(v: DVec3) -> Result<Self, Self::Error>
fn try_from(v: DVec3) -> Result<Self, Self::Error>
Tries to convert the source to Self in a lossy way, flooring any float value.
Errors
NaN
- If a float value isNaN
.NotFinite
- If a float value is infinity or negative infinity.PosOverflow
- If a float value would be greater than the the self.component max value.NegOverflow
- If a float value would be less than the self.component min value.
type Error = FloatConversionError
type Error = FloatConversionError
The type returned in the event of a conversion error.
sourceimpl TryFrom<Vec3> for UVec3
impl TryFrom<Vec3> for UVec3
sourcefn try_from(v: Vec3) -> Result<Self, Self::Error>
fn try_from(v: Vec3) -> Result<Self, Self::Error>
Tries to convert the source to Self in a lossy way, flooring any float value.
Errors
NaN
- If a float value isNaN
.NotFinite
- If a float value is infinity or negative infinity.PosOverflow
- If a float value would be greater than the the self.component max value.NegOverflow
- If a float value would be less than the self.component min value.
type Error = FloatConversionError
type Error = FloatConversionError
The type returned in the event of a conversion error.
impl Copy for UVec3
impl Eq for UVec3
impl Pod for UVec3
impl StructuralEq for UVec3
impl StructuralPartialEq for UVec3
Auto Trait Implementations
impl RefUnwindSafe for UVec3
impl Send for UVec3
impl Sync for UVec3
impl Unpin for UVec3
impl UnwindSafe for UVec3
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more