Skip to main content

Vec4

Struct Vec4 

Source
pub struct Vec4 {
    pub x: f32,
    pub y: f32,
    pub z: f32,
    pub w: f32,
}
Expand description

Vecteur 4D en f32.

Utile pour les coordonnées homogènes (w=1 pour un point, w=0 pour un vecteur de direction) et les couleurs RGBA.

Fields§

§x: f32

Composante X.

§y: f32

Composante Y.

§z: f32

Composante Z.

§w: f32

Composante W.

Implementations§

Source§

impl Vec4

Source

pub const ZERO: Self

Vecteur nul [0, 0, 0, 0].

Source

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

Crée un nouveau vecteur 4D.

Source

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

Retourne les composantes sous la forme [x, y, z, w].

Source

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

Crée un vecteur depuis un tableau [x, y, z, w].

Source

pub const fn from_vec3(v: Vec3, w: f32) -> Self

Construit un Vec4 depuis un Vec3 en ajoutant w.

Convention : w=1.0 pour un point, w=0.0 pour une direction.

Source

pub const fn xyz(&self) -> Vec3

Extrait les composantes XYZ comme Vec3, en ignorant w.

Source

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

Produit scalaire 4D : x₁x₂ + y₁y₂ + z₁z₂ + w₁w₂.

Source

pub fn norm_sq(&self) -> f32

Norme au carré. Infaillible.

Source

pub fn norm(&self) -> Result<f32, VecError>

Norme euclidienne via embedded_f32_sqrt.

Source

pub fn normalize(&self) -> Result<Self, VecError>

Vecteur unitaire dans la même direction.

Source

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

Interpolation linéaire.

Source

pub fn hadamard(&self, rhs: &Self) -> Self

Multiplication terme à terme (produit de Hadamard).

Source

pub fn is_finite(&self) -> bool

Retourne true si tous les composants sont finis.

Trait Implementations§

Source§

impl Add for Vec4

Source§

type Output = Vec4

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Vec4

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Vec4

Source§

fn clone(&self) -> Vec4

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 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, s: f32) -> Self

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, s: f32) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Vec4

Source§

fn mul_assign(&mut self, s: f32)

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 (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 Sub for Vec4

Source§

type Output = Vec4

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Vec4

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
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 UnsafeUnpin 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, 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.