Skip to main content

Vec4

Struct Vec4 

Source
#[repr(C)]
pub struct Vec4<T: VectorScalar> { pub x: T, pub y: T, pub z: T, pub w: T, }
Expand description

A 4D vector.

Fields§

§x: T

The x component of the vector.

§y: T

The y component of the vector.

§z: T

The z component of the vector.

§w: T

The w component of the vector.

Implementations§

Source§

impl<T: VectorScalar> Vec4<T>

Source

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

Creates a new vector with the given components.

Source§

impl<T> Vec4<T>
where T: VectorScalar,

Source

pub const fn splat(scalar: T) -> Self

Creates a new instance of the tuple type with all elements set to the given scalar value.

Source

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

Returns a raw pointer to the first element of the tuple.

Source

pub const fn as_mut_ptr(&mut self) -> *mut T

Returns a mutable raw pointer to the first element of the tuple.

Source

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

Returns a slice containing all elements of the tuple.

Source

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

Returns a mutable slice containing all elements of the tuple.

Source

pub const fn to_array(self) -> [T; 4]

Converts the tuple into an array of its scalar elements.

Source

pub const fn from_array(a: [T; 4]) -> Self

Creates a new instance of the tuple type from an array of scalar elements.

Source§

impl<T> Vec4<T>
where T: VectorScalar,

Source

pub fn dot(self, rhs: Self) -> T

Source§

impl<T> Vec4<T>
where T: VectorScalar + Select,

Source

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

Returns a vector containing the minimum values of each component of self and other.

Source

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

Returns a vector containing the maximum values of each component of self and other.

Source§

impl<T> Vec4<T>
where T: VectorScalar + Neg<Output = T>,

Source

pub fn negate(self) -> Self

Negates each component of the vector and returns a new vector.

Source§

impl<T> Vec4<T>
where T: VectorScalar,

Source

pub const ZERO: Self

Returns a vector with all components set to the additive identity (zero).

Source

pub fn is_zero(self) -> bool

Checks if all components of the vector are equal to the additive identity (zero).

Source§

impl<T> Vec4<T>
where T: VectorScalar,

Source

pub const ONE: Self

Returns a vector with all components set to the multiplicative identity (one).

Trait Implementations§

Source§

impl<T> AbsDiffEq for Vec4<T>
where T: VectorScalar + AbsDiffEq<Epsilon = T>,

Source§

type Epsilon = T

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl<T> Add for Vec4<T>
where T: VectorScalar,

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T> AddAssign for Vec4<T>
where T: VectorScalar,

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T> AsMut<[T]> for Vec4<T>
where T: VectorScalar,

Source§

fn as_mut(&mut self) -> &mut [T]

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

impl<T> AsRef<[T]> for Vec4<T>
where T: VectorScalar,

Source§

fn as_ref(&self) -> &[T]

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

impl<T: Clone + VectorScalar> Clone for Vec4<T>

Source§

fn clone(&self) -> Vec4<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy + VectorScalar> Copy for Vec4<T>

Source§

impl<T: Debug + VectorScalar> Debug for Vec4<T>

Source§

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

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

impl<T> Default for Vec4<T>
where T: VectorScalar,

Source§

fn default() -> Self

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

impl<T> Div for Vec4<T>
where T: VectorScalar,

Source§

type Output = Vec4<T>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T> DivAssign for Vec4<T>
where T: VectorScalar,

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl<T> DotProduct for Vec4<T>
where T: VectorScalar,

Source§

type Output = T

Source§

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

Computes the dot product of two values.
Source§

impl<T> From<Vec4<T>> for [T; 4]
where T: VectorScalar,

Source§

fn from(t: Vec4<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<[T; 4]> for Vec4<T>
where T: VectorScalar,

Source§

fn from(a: [T; 4]) -> Self

Converts to this type from the input type.
Source§

impl<T> HasScalar for Vec4<T>
where T: VectorScalar,

Source§

type Scalar = T

The associated scalar type for the implementing type.
Source§

impl<T> Index<usize> for Vec4<T>
where T: VectorScalar,

Source§

type Output = T

The returned type after indexing.
Source§

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

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

impl<T> IndexMut<usize> for Vec4<T>
where T: VectorScalar,

Source§

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

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

impl<T> Mul for Vec4<T>
where T: VectorScalar,

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T> MulAssign for Vec4<T>
where T: VectorScalar,

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<T> Neg for Vec4<T>
where T: VectorScalar + Neg<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> Negate for Vec4<T>
where T: VectorScalar + Neg<Output = T>,

Source§

fn negate(self) -> Self

Returns the additive inverse of the value.
Source§

impl<T> One for Vec4<T>
where T: VectorScalar,

Source§

const ONE: Self = Vec4<T>::ONE

The multiplicative identity for the type (typically 1).
Source§

impl<T: PartialEq + VectorScalar> PartialEq for Vec4<T>

Source§

fn eq(&self, other: &Vec4<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<T> RelativeEq for Vec4<T>
where T: VectorScalar + RelativeEq<Epsilon = T>,

Source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl<T> ScalarTuple for Vec4<T>
where T: VectorScalar,

Source§

const LEN: usize = 4

The number of scalar elements in the tuple.
Source§

type Array = [T; 4]

The array type corresponding to the tuple, containing the same number of scalar elements.
Source§

fn splat(scalar: Self::Scalar) -> Self

Creates a new instance of the tuple type with all elements set to the given scalar value.
Source§

fn as_ptr(&self) -> *const Self::Scalar

Returns a raw pointer to the first element of the tuple.
Source§

fn as_mut_ptr(&mut self) -> *mut Self::Scalar

Returns a mutable raw pointer to the first element of the tuple.
Source§

fn as_slice(&self) -> &[Self::Scalar]

Returns a slice containing all elements of the tuple.
Source§

fn as_mut_slice(&mut self) -> &mut [Self::Scalar]

Returns a mutable slice containing all elements of the tuple.
Source§

fn to_array(self) -> Self::Array

Converts the tuple into an array of its scalar elements.
Source§

fn from_array(a: Self::Array) -> Self

Creates a new instance of the tuple type from an array of scalar elements.
Source§

impl<T> Select for Vec4<T>
where T: VectorScalar + Select,

Source§

fn min_val(self, other: Self) -> Self

Returns the minimum of two values.
Source§

fn max_val(self, other: Self) -> Self

Returns the maximum of two values.
Source§

impl<T: PartialEq + VectorScalar> StructuralPartialEq for Vec4<T>

Source§

impl<T> Sub for Vec4<T>
where T: VectorScalar,

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T> SubAssign for Vec4<T>
where T: VectorScalar,

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<T> UlpsEq for Vec4<T>
where T: VectorScalar + UlpsEq<Epsilon = T>,

Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.
Source§

impl<T> Vector for Vec4<T>
where T: VectorScalar,

Source§

impl<T> Zero for Vec4<T>
where T: VectorScalar,

Source§

const ZERO: Self = Vec4<T>::ZERO

The additive identity for the type (typically 0).
Source§

fn is_zero(self) -> bool

Checks if the value is equal to the additive identity (zero).

Auto Trait Implementations§

§

impl<T> Freeze for Vec4<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vec4<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vec4<T>
where T: Send,

§

impl<T> Sync for Vec4<T>
where T: Sync,

§

impl<T> Unpin for Vec4<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Vec4<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Vec4<T>
where T: UnwindSafe,

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, 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.