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

source

pub const fn new(x: i32, y: i32, z: i32) -> Self

source

pub fn broadcast(val: i32) -> Self

source

pub fn unit_x() -> Self

source

pub fn unit_y() -> Self

source

pub fn unit_z() -> Self

source

pub fn cross(&self, other: IVec3) -> Self

source

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.

source

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.

source

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.

source

pub fn from_homogeneous_vector(v: IVec4) -> Self

Create a 3d vector from homogeneous 2d vector, which simply discards the homogeneous component.

source

pub fn dot(&self, other: IVec3) -> i32

source

pub fn reflect(&mut self, normal: IVec3)

source

pub fn reflected(&self, normal: IVec3) -> Self

source

pub fn mag(&self) -> i32

source

pub fn mag_sq(&self) -> i32

source

pub fn mul_add(&self, mul: IVec3, add: IVec3) -> Self

source

pub fn clamp(&mut self, min: Self, max: Self)

source

pub fn clamped(self, min: Self, max: Self) -> Self

source

pub fn map<F>(&self, f: F) -> Selfwhere F: FnMut(i32) -> i32,

source

pub fn apply<F>(&mut self, f: F)where F: FnMut(i32) -> i32,

source

pub fn max_by_component(self, other: Self) -> Self

source

pub fn min_by_component(self, other: Self) -> Self

source

pub fn component_max(&self) -> i32

source

pub fn component_min(&self) -> i32

source

pub fn zero() -> Self

source

pub fn one() -> Self

source

pub fn xy(&self) -> IVec2

source

pub fn xyzw(&self) -> IVec4

source

pub fn layout() -> Layout

source

pub fn as_slice(&self) -> &[i32]

source

pub fn as_array(&self) -> [i32; 3]

source

pub fn as_byte_slice(&self) -> &[u8]

source

pub fn as_mut_slice(&mut self) -> &mut [i32]

source

pub fn as_mut_byte_slice(&mut self) -> &mut [u8]

source

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.

source

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.

source§

impl IVec3

source

pub fn abs(&self) -> Self

Trait Implementations§

source§

impl Add<IVec3> for IVec3

§

type Output = IVec3

The resulting type after applying the + operator.
source§

fn add(self, rhs: IVec3) -> Self

Performs the + operation. Read more
source§

impl AddAssign<IVec3> for IVec3

source§

fn add_assign(&mut self, rhs: IVec3)

Performs the += operation. Read more
source§

impl Clone for IVec3

source§

fn clone(&self) -> IVec3

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 Debug for IVec3

source§

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

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

impl Default for IVec3

source§

fn default() -> IVec3

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

impl<'de> Deserialize<'de> for IVec3

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Div<IVec3> for IVec3

§

type Output = IVec3

The resulting type after applying the / operator.
source§

fn div(self, rhs: IVec3) -> Self

Performs the / operation. Read more
source§

impl Div<i32> for IVec3

§

type Output = IVec3

The resulting type after applying the / operator.
source§

fn div(self, rhs: i32) -> IVec3

Performs the / operation. Read more
source§

impl DivAssign<IVec3> for IVec3

source§

fn div_assign(&mut self, rhs: IVec3)

Performs the /= operation. Read more
source§

impl DivAssign<i32> for IVec3

source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
source§

impl From<&[i32; 3]> for IVec3

source§

fn from(comps: &[i32; 3]) -> Self

Converts to this type from the input type.
source§

impl From<&(i32, i32, i32)> for IVec3

source§

fn from(comps: &(i32, i32, i32)) -> Self

Converts to this type from the input type.
source§

impl From<&mut [i32; 3]> for IVec3

source§

fn from(comps: &mut [i32; 3]) -> Self

Converts to this type from the input type.
source§

impl From<[i32; 3]> for IVec3

source§

fn from(comps: [i32; 3]) -> Self

Converts to this type from the input type.
source§

impl From<(i32, i32, i32)> for IVec3

source§

fn from(comps: (i32, i32, i32)) -> Self

Converts to this type from the input type.
source§

impl From<IVec3> for [i32; 3]

source§

fn from(v: IVec3) -> Self

Converts to this type from the input type.
source§

impl From<IVec3> for (i32, i32, i32)

source§

fn from(v: IVec3) -> Self

Converts to this type from the input type.
source§

impl From<IVec3> for DVec3

source§

fn from(v: IVec3) -> Self

Converts to this type from the input type.
source§

impl From<IVec3> for IVec2

source§

fn from(vec: IVec3) -> Self

Converts to this type from the input type.
source§

impl From<IVec3> for IVec4

source§

fn from(vec: IVec3) -> Self

Converts to this type from the input type.
source§

impl From<IVec3> for Vec3

source§

fn from(v: IVec3) -> Self

Converts to this type from the input type.
source§

impl From<IVec4> for IVec3

source§

fn from(vec: IVec4) -> Self

Converts to this type from the input type.
source§

impl Hash for IVec3

source§

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

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 Index<usize> for IVec3

§

type Output = i32

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for IVec3

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl Mul<IVec3> for IVec3

§

type Output = IVec3

The resulting type after applying the * operator.
source§

fn mul(self, rhs: IVec3) -> Self

Performs the * operation. Read more
source§

impl Mul<IVec3> for i32

§

type Output = IVec3

The resulting type after applying the * operator.
source§

fn mul(self, rhs: IVec3) -> IVec3

Performs the * operation. Read more
source§

impl Mul<i32> for IVec3

§

type Output = IVec3

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> IVec3

Performs the * operation. Read more
source§

impl MulAssign<IVec3> for IVec3

source§

fn mul_assign(&mut self, rhs: IVec3)

Performs the *= operation. Read more
source§

impl MulAssign<i32> for IVec3

source§

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
source§

impl Neg for IVec3

§

type Output = IVec3

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl PartialEq<IVec3> for IVec3

source§

fn eq(&self, other: &IVec3) -> 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 Serialize for IVec3

source§

fn serialize<T>(&self, serializer: T) -> Result<T::Ok, T::Error>where T: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub<IVec3> for IVec3

§

type Output = IVec3

The resulting type after applying the - operator.
source§

fn sub(self, rhs: IVec3) -> Self

Performs the - operation. Read more
source§

impl SubAssign<IVec3> for IVec3

source§

fn sub_assign(&mut self, rhs: IVec3)

Performs the -= operation. Read more
source§

impl TryFrom<DVec3> for IVec3

source§

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 is NaN.
  • 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

The type returned in the event of a conversion error.
source§

impl TryFrom<IVec3> for UVec3

§

type Error = <u32 as TryFrom<i32>>::Error

The type returned in the event of a conversion error.
source§

fn try_from(rhv: IVec3) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<UVec3> for IVec3

§

type Error = <i32 as TryFrom<u32>>::Error

The type returned in the event of a conversion error.
source§

fn try_from(rhv: UVec3) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Vec3> for IVec3

source§

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 is NaN.
  • 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

The type returned in the event of a conversion error.
source§

impl Zeroable for IVec3

source§

fn zeroed() -> Self

source§

impl Copy for IVec3

source§

impl Eq for IVec3

source§

impl Pod for IVec3

source§

impl StructuralEq for IVec3

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere T: Pod,

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> NoUninit for Twhere T: Pod,