Skip to main content

Vec4

Struct Vec4 

Source
#[repr(C, align(16))]
pub struct Vec4 { pub x: f32, pub y: f32, pub z: f32, pub w: f32, }

Fields§

§x: f32§y: f32§z: f32§w: f32

Implementations§

Source§

impl Vec4

Source

pub const ZERO: Vec4

Source

pub const ONE: Vec4

Source

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

Source

pub fn length(self) -> f32

Source

pub fn length_squared(self) -> f32

Source

pub fn normalize(self) -> Self

Source

pub fn normalize_fast(self) -> Self

Normalize using rsqrt approximation. Less accurate than normalize() but faster; uses SIMD when the feature is on.

Source

pub fn dot(self, other: Self) -> f32

Source

pub fn lerp(self, other: Self, t: f32) -> Self

Source

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

Source

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

Source

pub fn splat(value: f32) -> Self

All components set to the same value.

Source

pub fn abs(self) -> Self

Component-wise absolute value

Source

pub fn recip(self) -> Self

Component-wise reciprocal

Source

pub fn signum(self) -> Self

Component-wise signum

Source

pub fn min_element(self) -> f32

Minimum element

Source

pub fn max_element(self) -> f32

Maximum element

Source

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

Component-wise clamp

Source

pub fn truncate(self) -> Vec3

Truncate to Vec3 (drop w component)

Source

pub fn is_finite(self) -> bool

Check if all components are finite

Source

pub fn is_nan(self) -> bool

Check if any component is NaN

Source

pub fn abs_diff_eq(self, other: Self, epsilon: f32) -> bool

Approximate equality with epsilon

Source

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

Create from array

Source

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

Convert to array

Source

pub fn from_slice(slice: &[f32]) -> Option<Self>

Create from slice, returns None if slice is too short

Source

pub fn write_to_slice(self, slice: &mut [f32])

Write to slice, panics if slice is too short

Source

pub fn as_array(&self) -> &[f32; 4]

Get reference to underlying array

Source

pub fn as_array_mut(&mut self) -> &mut [f32; 4]

Get mutable reference to underlying array

Trait Implementations§

Source§

impl Add for Vec4

Source§

type Output = Vec4

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AsMut<[f32; 4]> for Vec4

Source§

fn as_mut(&mut self) -> &mut [f32; 4]

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

impl AsRef<[f32; 4]> for Vec4

Source§

fn as_ref(&self) -> &[f32; 4]

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

impl Clone for Vec4

Source§

fn clone(&self) -> Vec4

Returns a duplicate 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 Vec4

Source§

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

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

impl Div<f32> for Vec4

Source§

type Output = Vec4

The resulting type after applying the / operator.
Source§

fn div(self, scalar: f32) -> Self

Performs the / operation. Read more
Source§

impl Div for Vec4

Source§

type Output = Vec4

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl From<Vec4> for IVec4

Source§

fn from(v: Vec4) -> Self

Converts to this type from the input type.
Source§

impl Mul<Vec4> for Mat4

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

fn mul(self, other: Vec4) -> Vec4

Performs the * operation. Read more
Source§

impl Mul<Vec4> for f32

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

fn mul(self, vec: Vec4) -> Vec4

Performs the * operation. Read more
Source§

impl Mul<f32> for Vec4

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: f32) -> Self

Performs the * operation. Read more
Source§

impl Mul for Vec4

Source§

type Output = Vec4

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Neg for Vec4

Source§

type Output = Vec4

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Vec4

Source§

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

Source§

type Output = Vec4

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Vec4Swizzles for Vec4

Source§

fn x(self) -> f32

Source§

fn y(self) -> f32

Source§

fn z(self) -> f32

Source§

fn w(self) -> f32

Source§

fn xx(self) -> Vec2

Source§

fn xy(self) -> Vec2

Source§

fn xz(self) -> Vec2

Source§

fn xw(self) -> Vec2

Source§

fn yx(self) -> Vec2

Source§

fn yy(self) -> Vec2

Source§

fn yz(self) -> Vec2

Source§

fn yw(self) -> Vec2

Source§

fn zx(self) -> Vec2

Source§

fn zy(self) -> Vec2

Source§

fn zz(self) -> Vec2

Source§

fn zw(self) -> Vec2

Source§

fn wx(self) -> Vec2

Source§

fn wy(self) -> Vec2

Source§

fn wz(self) -> Vec2

Source§

fn ww(self) -> Vec2

Source§

fn xyz(self) -> Vec3

Source§

fn xyw(self) -> Vec3

Source§

fn xzy(self) -> Vec3

Source§

fn xzw(self) -> Vec3

Source§

fn xwy(self) -> Vec3

Source§

fn xwz(self) -> Vec3

Source§

fn yxz(self) -> Vec3

Source§

fn yxw(self) -> Vec3

Source§

fn yzx(self) -> Vec3

Source§

fn yzw(self) -> Vec3

Source§

fn ywx(self) -> Vec3

Source§

fn ywz(self) -> Vec3

Source§

fn zxy(self) -> Vec3

Source§

fn zxw(self) -> Vec3

Source§

fn zyx(self) -> Vec3

Source§

fn zyw(self) -> Vec3

Source§

fn zwx(self) -> Vec3

Source§

fn zwy(self) -> Vec3

Source§

fn wxy(self) -> Vec3

Source§

fn wxz(self) -> Vec3

Source§

fn wyx(self) -> Vec3

Source§

fn wyz(self) -> Vec3

Source§

fn wzx(self) -> Vec3

Source§

fn wzy(self) -> Vec3

Source§

fn xyzw(self) -> Vec4

Source§

fn xywz(self) -> Vec4

Source§

fn xzyw(self) -> Vec4

Source§

fn xzwy(self) -> Vec4

Source§

fn xwyz(self) -> Vec4

Source§

fn xwzy(self) -> Vec4

Source§

fn yxzw(self) -> Vec4

Source§

fn yxwz(self) -> Vec4

Source§

fn yzxw(self) -> Vec4

Source§

fn yzwx(self) -> Vec4

Source§

fn ywxz(self) -> Vec4

Source§

fn ywzx(self) -> Vec4

Source§

fn zxyw(self) -> Vec4

Source§

fn zxwy(self) -> Vec4

Source§

fn zyxw(self) -> Vec4

Source§

fn zywx(self) -> Vec4

Source§

fn zwxy(self) -> Vec4

Source§

fn zwyx(self) -> Vec4

Source§

fn wxyz(self) -> Vec4

Source§

fn wxzy(self) -> Vec4

Source§

fn wyxz(self) -> Vec4

Source§

fn wyzx(self) -> Vec4

Source§

fn wzxy(self) -> Vec4

Source§

fn wzyx(self) -> Vec4

Source§

impl Copy for Vec4

Source§

impl StructuralPartialEq for Vec4

Auto Trait Implementations§

§

impl Freeze for Vec4

§

impl RefUnwindSafe for Vec4

§

impl Send for Vec4

§

impl Sync for Vec4

§

impl Unpin for Vec4

§

impl UnwindSafe for Vec4

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.