Struct ultraviolet::int::IVec3
source · #[repr(C)]pub struct IVec3 {
pub x: i32,
pub y: i32,
pub z: i32,
}
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: i32
§y: i32
§z: i32
Implementations§
source§impl IVec3
impl IVec3
pub const fn new(x: i32, y: i32, z: i32) -> Self
pub fn broadcast(val: i32) -> Self
pub fn unit_x() -> Self
pub fn unit_y() -> Self
pub fn unit_z() -> Self
pub fn cross(&self, other: IVec3) -> Self
sourcepub fn into_homogeneous_point(self) -> IVec4
pub fn into_homogeneous_point(self) -> IVec4
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) -> IVec4
pub fn into_homogeneous_vector(self) -> IVec4
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: IVec4) -> Self
pub fn from_homogeneous_point(v: IVec4) -> 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: IVec4) -> Self
pub fn from_homogeneous_vector(v: IVec4) -> Self
Create a 3d vector from homogeneous 2d vector, which simply discards the homogeneous component.
pub fn dot(&self, other: IVec3) -> i32
pub fn reflect(&mut self, normal: IVec3)
pub fn reflected(&self, normal: IVec3) -> Self
pub fn mag(&self) -> i32
pub fn mag_sq(&self) -> i32
pub fn mul_add(&self, mul: IVec3, add: IVec3) -> 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(i32) -> i32,
pub fn apply<F>(&mut self, f: F)where F: FnMut(i32) -> i32,
pub fn max_by_component(self, other: Self) -> Self
pub fn min_by_component(self, other: Self) -> Self
pub fn component_max(&self) -> i32
pub fn component_min(&self) -> i32
pub fn zero() -> Self
pub fn one() -> Self
pub fn xy(&self) -> IVec2
pub fn xyzw(&self) -> IVec4
pub fn layout() -> Layout
pub fn as_slice(&self) -> &[i32]
pub fn as_array(&self) -> [i32; 3]
pub fn as_byte_slice(&self) -> &[u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [i32]
pub fn as_mut_byte_slice(&mut self) -> &mut [u8] ⓘ
sourcepub fn as_ptr(&self) -> *const i32
pub fn as_ptr(&self) -> *const i32
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 i32
pub fn as_mut_ptr(&mut self) -> *mut i32
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<IVec3> for IVec3
impl AddAssign<IVec3> for IVec3
source§fn add_assign(&mut self, rhs: IVec3)
fn add_assign(&mut self, rhs: IVec3)
+=
operation. Read moresource§impl<'de> Deserialize<'de> for IVec3
impl<'de> Deserialize<'de> for IVec3
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<IVec3> for IVec3
impl DivAssign<IVec3> for IVec3
source§fn div_assign(&mut self, rhs: IVec3)
fn div_assign(&mut self, rhs: IVec3)
/=
operation. Read moresource§impl DivAssign<i32> for IVec3
impl DivAssign<i32> for IVec3
source§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
/=
operation. Read moresource§impl MulAssign<IVec3> for IVec3
impl MulAssign<IVec3> for IVec3
source§fn mul_assign(&mut self, rhs: IVec3)
fn mul_assign(&mut self, rhs: IVec3)
*=
operation. Read moresource§impl MulAssign<i32> for IVec3
impl MulAssign<i32> for IVec3
source§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*=
operation. Read moresource§impl PartialEq<IVec3> for IVec3
impl PartialEq<IVec3> for IVec3
source§impl SubAssign<IVec3> for IVec3
impl SubAssign<IVec3> for IVec3
source§fn sub_assign(&mut self, rhs: IVec3)
fn sub_assign(&mut self, rhs: IVec3)
-=
operation. Read moresource§impl TryFrom<DVec3> for IVec3
impl TryFrom<DVec3> for IVec3
source§fn 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
source§impl TryFrom<Vec3> for IVec3
impl TryFrom<Vec3> for IVec3
source§fn 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
impl Copy for IVec3
impl Eq for IVec3
impl Pod for IVec3
impl StructuralEq for IVec3
impl StructuralPartialEq for IVec3
Auto Trait Implementations§
impl RefUnwindSafe for IVec3
impl Send for IVec3
impl Sync for IVec3
impl Unpin for IVec3
impl UnwindSafe for IVec3
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
.