Skip to main content

vec4

Struct vec4 

Source
#[repr(C)]
pub struct vec4<T>(pub T, pub T, pub T, pub T);
Expand description

4 dimensional vector.

Tuple Fields§

§0: T§1: T§2: T§3: T

Implementations§

Source§

impl<T> vec4<T>

Source

pub fn xy(self) -> vec2<T>

Get first two components as a vec2

Source

pub fn xyz(self) -> vec3<T>

Get first three components as a vec3

Source

pub fn map<U, F: Fn(T) -> U>(self, f: F) -> vec4<U>

Map every value (coordinate).

Source

pub fn zip<U>(self, v: vec4<U>) -> vec4<(T, U)>

Zip two vectors together

Source§

impl<T: Clone> vec4<T>

Source

pub fn splat(value: T) -> Self

Construct a vector with all components set to specified value

Source§

impl<T: UNum> vec4<T>

Source

pub const ZERO: Self

A zero 4-d vector

Source

pub const UNIT_X: Self

A unit X

Source

pub const UNIT_Y: Self

A unit Y

Source

pub const UNIT_Z: Self

A unit Z

Source

pub const UNIT_W: Self

A unit W

Source§

impl<T: Copy + Num> vec4<T>

Source

pub fn dot(a: Self, b: Self) -> T

Calculate dot product of two vectors.

§Examples
assert_eq!(vec4::dot(vec4(1, 2, 3, 4), vec4(3, 4, 5, 6)), 50);
Source§

impl<T: Float> vec4<T>

Source

pub fn into_3d(self) -> vec3<T>

Convert a homogenous 4d vector into 3d

Same as self.xyz() / self.w

Trait Implementations§

Source§

impl<T: Add<Output = T>> Add for vec4<T>

Source§

type Output = vec4<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: AddAssign> AddAssign for vec4<T>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: Clone> 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> Copy for vec4<T>

Source§

impl<T: Debug> Debug for vec4<T>

Source§

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

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

impl<T> Deref for vec4<T>

Source§

type Target = XYZW<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &XYZW<T>

Dereferences the value.
Source§

impl<T> DerefMut for vec4<T>

Source§

fn deref_mut(&mut self) -> &mut XYZW<T>

Mutably dereferences the value.
Source§

impl<'de, T> Deserialize<'de> for vec4<T>
where T: Deserialize<'de>,

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<T: Display> Display for vec4<T>

Source§

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

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

impl<T: Div<Output = T>> Div for vec4<T>

Source§

type Output = vec4<T>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T: Copy + Div<Output = T>> Div<T> for vec4<T>

Source§

type Output = vec4<T>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T: DivAssign> DivAssign for vec4<T>

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl<T: Copy + DivAssign> DivAssign<T> for vec4<T>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T: Eq> Eq for vec4<T>

Source§

impl<T> From<[T; 4]> for vec4<T>

Source§

fn from(arr: [T; 4]) -> vec4<T>

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for vec4<T>

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<T: Mul<Output = T>> Mul for vec4<T>

Source§

type Output = vec4<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Copy + Mul<Output = T>> Mul<T> for vec4<T>

Source§

type Output = vec4<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Num + Copy> Mul<vec4<T>> for mat4<T>

Source§

type Output = vec4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<T>) -> vec4<T>

Performs the * operation. Read more
Source§

impl Mul<vec4<f32>> for f32

Source§

type Output = vec4<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<f32>) -> vec4<f32>

Performs the * operation. Read more
Source§

impl Mul<vec4<f64>> for f64

Source§

type Output = vec4<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<f64>) -> vec4<f64>

Performs the * operation. Read more
Source§

impl Mul<vec4<i8>> for i8

Source§

type Output = vec4<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<i8>) -> vec4<i8>

Performs the * operation. Read more
Source§

impl Mul<vec4<i16>> for i16

Source§

type Output = vec4<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<i16>) -> vec4<i16>

Performs the * operation. Read more
Source§

impl Mul<vec4<i32>> for i32

Source§

type Output = vec4<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<i32>) -> vec4<i32>

Performs the * operation. Read more
Source§

impl Mul<vec4<i64>> for i64

Source§

type Output = vec4<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<i64>) -> vec4<i64>

Performs the * operation. Read more
Source§

impl Mul<vec4<isize>> for isize

Source§

type Output = vec4<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<isize>) -> vec4<isize>

Performs the * operation. Read more
Source§

impl Mul<vec4<u8>> for u8

Source§

type Output = vec4<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<u8>) -> vec4<u8>

Performs the * operation. Read more
Source§

impl Mul<vec4<u16>> for u16

Source§

type Output = vec4<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<u16>) -> vec4<u16>

Performs the * operation. Read more
Source§

impl Mul<vec4<u32>> for u32

Source§

type Output = vec4<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<u32>) -> vec4<u32>

Performs the * operation. Read more
Source§

impl Mul<vec4<u64>> for u64

Source§

type Output = vec4<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<u64>) -> vec4<u64>

Performs the * operation. Read more
Source§

impl Mul<vec4<usize>> for usize

Source§

type Output = vec4<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: vec4<usize>) -> vec4<usize>

Performs the * operation. Read more
Source§

impl<T: MulAssign> MulAssign for vec4<T>

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<T: Copy + MulAssign> MulAssign<T> for vec4<T>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: Neg<Output = T>> Neg for vec4<T>

Source§

type Output = vec4<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: PartialEq> PartialEq for vec4<T>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T> Serialize for vec4<T>
where T: Serialize,

Source§

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

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

impl<T: PartialEq> StructuralPartialEq for vec4<T>

Source§

impl<T: Sub<Output = T>> Sub for vec4<T>

Source§

type Output = vec4<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T: SubAssign> SubAssign for vec4<T>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V