alloy::math::vec

Struct Vector3u

source
#[repr(C)]
pub struct Vector3u { pub x: u32, pub y: u32, pub z: u32, }
Expand description

An owning representation of an unsigned 3-component Euclidean vector.

Like Vec3u, the Vector3u object represents a Euclidean vector in 3D. Unlike the Vec3u, this is an owning representation that stores the actual content of the vector.

Fields§

§x: u32

The X-component of the vector.

§y: u32

The Y-component of the vector.

§z: u32

The Z-component of the vector.

Implementations§

source§

impl Vector3u

source

pub const ZERO: Vector3u = _

A constant for a Null vector, which has magnitude 0 and exists at the origin.

source

pub const UNIT_X: Vector3u = _

A constant for a unit vector in the positive X-direction.

source

pub const UNIT_Y: Vector3u = _

A constant for a unit vector in the positive Y-direction.

source

pub const UNIT_Z: Vector3u = _

A constant for a unit vector in the positive Z-direction.

source

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

Constructs this vector from an x, y, and z coordinate.

§Parameters
  • x - the x-component
  • y - the y-component
  • z - the z-component
source

pub const fn uniform(v: u32) -> Self

Constructs this vector with a uniform value v.

§Parameters
  • v - the value to uniformly apply
source

pub const fn from_array(array: &[u32; 3]) -> Self

Constructs this vector from a 3-component u32 array.

§Parameters
  • array - an array containing 3 u32 values.
source

pub const fn from_slice(slice: &[u32]) -> Result<Self, VecError>

Constructs this vector from a slice of floats.

This will return VecError if slice.len() is not equal to 2.

§Parameters
  • slice - the slice to read from
source

pub const unsafe fn from_slice_unchecked(slice: &[u32]) -> Self

Constructs this vector from a slice of floats.

§Parameters
  • slice - the slice to read from
§Safety

slice.len() must be greater or equal to 2, otherwise this will access an out-of-bounds entry and panic.

source

pub fn from_vec3u(other: &Vec3u) -> Self

Constructs this vector from a Vec3u

§Parameters
  • other - the other vector
source

pub const unsafe fn from_ptr(ptr: *const u32) -> Self

Constructs this vector from a pointer to floating point values.

§Parameters
  • ptr - the pointer to the start of a contiguous sequence of floats
§Safety

This function requires that ptr be non-null and point to the start of a contiguous sequence of 3 u32 values.

source

pub const fn as_vec3u(&self) -> &Vec3u

Returns this vector as a Vec3u.

source

pub fn as_mut_vec3u(&mut self) -> &mut Vec3u

Returns this vector as a mutable Vec3u.

source

pub const fn as_slice(&self) -> &[u32]

Returns this vector as a slice of u32.

source

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

Returns this vector as a mutable slice of u32.

Methods from Deref<Target = Vec3u>§

source

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

Returns this Vec3u as a slice of u32.

source

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

Returns this Vec3u as a mutable slice of u32.

source

pub fn as_ptr(&self) -> *const u32

Returns a raw pointer to u32 of the vector’s buffer.

source

pub fn as_mut_ptr(&mut self) -> *mut u32

Returns a mutable raw pointer to u32 of the vector’s buffer.

source

pub fn iter(&self) -> impl Iterator<Item = &u32>

Returns an iterator over the vector.

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut u32>

Returns a mutable iterator over the vector.

source

pub fn x(&self) -> u32

Returns the X-coordinate of this 3-component vector.

source

pub fn y(&self) -> u32

Returns the Y-coordinate of this 3-component vector.

source

pub fn z(&self) -> u32

Returns the Z-coordinate of this 3-component vector.

source

pub fn xy(&self) -> &Vec2u

Returns the xy coordinates of this vector as a Vec3u.

source

pub fn yz(&self) -> &Vec2u

Returns the yz coordinates of this vector as a Vec3u.

source

pub fn x_mut(&mut self) -> &mut u32

Returns a mutable reference to the X-coordinate of this 3-component vector.

source

pub fn y_mut(&mut self) -> &mut u32

Returns a mutable reference to the Y-coordinate of this 3-component vector.

source

pub fn z_mut(&mut self) -> &mut u32

Returns a mutable reference to the Z-coordinate of this 3-component vector.

source

pub fn xy_mut(&mut self) -> &mut Vec2u

Returns a mutable reference to the xy coordinates of this vector.

source

pub fn yz_mut(&mut self) -> &mut Vec2u

Returns a mutable reference to the yz coordinates of this vector.

source

pub fn set_x(&mut self, x: u32)

Sets the x-component

§Parameters
  • x - the X-component
source

pub fn set_y(&mut self, y: u32)

Sets the y-component

§Parameters
  • y - the Y-component
source

pub fn set_z(&mut self, z: u32)

Sets the z-component

§Parameters
  • z - the Z-component
source

pub fn set_xy(&mut self, xy: &Vec2u)

Sets the X and Y components of this vector

§Parameters
  • xy - the X and Y components o
source

pub fn set_yz(&mut self, xy: &Vec2u)

Sets the Y and Z components of this vector

§Parameters
  • yz - the Y and Z components of the Vec3u
source

pub fn set(&mut self, other: &Vec3u)

Sets all the components of this vector the values from other.

§Parameters
  • other - the other Vec3u to set.
source

pub fn min(&self, rhs: &Vec3u) -> Vector3u

Computes the minimum of each vector.

§Parameters
  • lhs - the left vector
  • rhs - the right vector
source

pub fn max(&self, rhs: &Vec3u) -> Vector3u

Computes the maximum of each vector.

§Parameters
  • lhs - the left vector
  • rhs - the right vector

Trait Implementations§

source§

impl Add<&Vec3u> for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Vec3u) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&Vec3u> for Vector3u

source§

type Output = Vector3u

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Vec3u) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&Vector3u> for &Vec3u

source§

type Output = Vector3u

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Vector3u) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&Vector3u> for Vector3u

source§

type Output = Vector3u

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Vector3u) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Vector3u> for &Vec3u

source§

type Output = Vector3u

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vector3u) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Vector3u> for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vector3u) -> Self::Output

Performs the + operation. Read more
source§

impl Add for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add for Vector3u

source§

type Output = Vector3u

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl AddAssign<&Vec3u> for Vector3u

source§

fn add_assign(&mut self, rhs: &Vec3u)

Performs the += operation. Read more
source§

impl AddAssign<&Vector3u> for Vector3u

source§

fn add_assign(&mut self, rhs: &Self)

Performs the += operation. Read more
source§

impl AddAssign for Vector3u

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl AsMut<Vec3u> for Vector3u

source§

fn as_mut(&mut self) -> &mut Vec3u

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<Vec3u> for Vector3u

source§

fn as_ref(&self) -> &Vec3u

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<Vec3u> for Vector3u

source§

fn borrow(&self) -> &Vec3u

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<Vec3u> for Vector3u

source§

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

Mutably borrows from an owned value. Read more
source§

impl Clone for Vector3u

source§

fn clone(&self) -> Vector3u

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 Vector3u

source§

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

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

impl Default for Vector3u

source§

fn default() -> Vector3u

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

impl Deref for Vector3u

source§

type Target = Vec3u

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for Vector3u

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl Display for Vector3u

source§

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

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

impl Div<u32> for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the / operator.
source§

fn div(self, rhs: u32) -> Self::Output

Performs the / operation. Read more
source§

impl Div<u32> for Vector3u

source§

type Output = Vector3u

The resulting type after applying the / operator.
source§

fn div(self, rhs: u32) -> Self::Output

Performs the / operation. Read more
source§

impl DivAssign<u32> for Vector3u

source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
source§

impl From<&Vec3u> for Vector3u

source§

fn from(value: &Vec3u) -> Self

Converts to this type from the input type.
source§

impl Mul<&Vector3u> for u32

source§

type Output = Vector3u

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Vector3u) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Vector3u> for u32

source§

type Output = Vector3u

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vector3u) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u32> for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u32> for Vector3u

source§

type Output = Vector3u

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
source§

impl MulAssign<u32> for Vector3u

source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
source§

impl Ord for Vector3u

source§

fn cmp(&self, other: &Vector3u) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Vector3u

source§

fn eq(&self, other: &Vector3u) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Vector3u

source§

fn partial_cmp(&self, other: &Vector3u) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Rem<u32> for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the % operator.
source§

fn rem(self, rhs: u32) -> Self::Output

Performs the % operation. Read more
source§

impl Rem<u32> for Vector3u

source§

type Output = Vector3u

The resulting type after applying the % operator.
source§

fn rem(self, rhs: u32) -> Self::Output

Performs the % operation. Read more
source§

impl RemAssign<u32> for Vector3u

source§

fn rem_assign(&mut self, rhs: u32)

Performs the %= operation. Read more
source§

impl Sub<&Vec3u> for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Vec3u) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<&Vec3u> for Vector3u

source§

type Output = Vector3u

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Vec3u) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<&Vector3u> for &Vec3u

source§

type Output = Vector3u

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Vector3u) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<&Vector3u> for Vector3u

source§

type Output = Vector3u

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Vector3u) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Vector3u> for &Vec3u

source§

type Output = Vector3u

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Vector3u) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<Vector3u> for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Vector3u) -> Self::Output

Performs the - operation. Read more
source§

impl Sub for &Vector3u

source§

type Output = Vector3u

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub for Vector3u

source§

type Output = Vector3u

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl SubAssign<&Vec3u> for Vector3u

source§

fn sub_assign(&mut self, rhs: &Vec3u)

Performs the -= operation. Read more
source§

impl SubAssign<&Vector3u> for Vector3u

source§

fn sub_assign(&mut self, rhs: &Self)

Performs the -= operation. Read more
source§

impl SubAssign for Vector3u

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl Copy for Vector3u

source§

impl Eq for Vector3u

source§

impl StructuralPartialEq for Vector3u

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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 T
where T: Clone,

source§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

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 T
where U: TryFrom<T>,

source§

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.