Struct ultraviolet::int::UVec2
source · #[repr(C)]pub struct UVec2 {
pub x: u32,
pub y: u32,
}
Expand description
A set of two coordinates which may be interpreted as a vector or point in 2d space.
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
Implementations§
source§impl UVec2
impl UVec2
pub const fn new(x: u32, y: u32) -> Self
pub fn broadcast(val: u32) -> Self
pub fn unit_x() -> Self
pub fn unit_y() -> Self
sourcepub fn into_homogeneous_point(self) -> UVec3
pub fn into_homogeneous_point(self) -> UVec3
Create a homogeneous 2d 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) -> UVec3
pub fn into_homogeneous_vector(self) -> UVec3
Create a homogeneous 2d vector from this vector, meaning the homogeneous component will always have a value of 0.
sourcepub fn from_homogeneous_point(v: UVec3) -> Self
pub fn from_homogeneous_point(v: UVec3) -> Self
Create a 2d point from a homogeneous 2d point, performing division by the homogeneous component. This should not be used for homogeneous 2d vectors, which will have 0 as their homogeneous component.
sourcepub fn from_homogeneous_vector(v: UVec3) -> Self
pub fn from_homogeneous_vector(v: UVec3) -> Self
Create a 2d vector from homogeneous 2d vector, which simply discards the homogeneous component.
pub fn dot(&self, other: UVec2) -> u32
pub fn reflected(&self, normal: UVec2) -> Self
pub fn mag(&self) -> u32
pub fn mag_sq(&self) -> u32
pub fn mul_add(&self, mul: UVec2, add: UVec2) -> 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) -> Selfwhere 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 xyz(&self) -> UVec3
pub fn xyzw(&self) -> UVec4
pub fn layout() -> Layout
pub fn as_slice(&self) -> &[u32]
pub fn as_array(&self) -> [u32; 2]
pub fn as_byte_slice(&self) -> &[u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u32]
pub fn as_mut_byte_slice(&mut self) -> &mut [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§
source§impl AddAssign<UVec2> for UVec2
impl AddAssign<UVec2> for UVec2
source§fn add_assign(&mut self, rhs: UVec2)
fn add_assign(&mut self, rhs: UVec2)
+=
operation. Read moresource§impl<'de> Deserialize<'de> for UVec2
impl<'de> Deserialize<'de> for UVec2
source§fn 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>,
source§impl DivAssign<UVec2> for UVec2
impl DivAssign<UVec2> for UVec2
source§fn div_assign(&mut self, rhs: UVec2)
fn div_assign(&mut self, rhs: UVec2)
/=
operation. Read moresource§impl DivAssign<u32> for UVec2
impl DivAssign<u32> for UVec2
source§fn div_assign(&mut self, rhs: u32)
fn div_assign(&mut self, rhs: u32)
/=
operation. Read moresource§impl MulAssign<UVec2> for UVec2
impl MulAssign<UVec2> for UVec2
source§fn mul_assign(&mut self, rhs: UVec2)
fn mul_assign(&mut self, rhs: UVec2)
*=
operation. Read moresource§impl MulAssign<u32> for UVec2
impl MulAssign<u32> for UVec2
source§fn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
*=
operation. Read moresource§impl PartialEq<UVec2> for UVec2
impl PartialEq<UVec2> for UVec2
source§impl SubAssign<UVec2> for UVec2
impl SubAssign<UVec2> for UVec2
source§fn sub_assign(&mut self, rhs: UVec2)
fn sub_assign(&mut self, rhs: UVec2)
-=
operation. Read moresource§impl TryFrom<DVec2> for UVec2
impl TryFrom<DVec2> for UVec2
source§fn try_from(v: DVec2) -> Result<Self, Self::Error>
fn try_from(v: DVec2) -> 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
source§impl TryFrom<Vec2> for UVec2
impl TryFrom<Vec2> for UVec2
source§fn try_from(v: Vec2) -> Result<Self, Self::Error>
fn try_from(v: Vec2) -> 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
impl Copy for UVec2
impl Eq for UVec2
impl Pod for UVec2
impl StructuralEq for UVec2
impl StructuralPartialEq for UVec2
Auto Trait Implementations§
impl RefUnwindSafe for UVec2
impl Send for UVec2
impl Sync for UVec2
impl Unpin for UVec2
impl UnwindSafe for UVec2
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
.