Type Alias citro3d::math::FVec4

source ·
pub type FVec4 = FVec<4>;
Expand description

A 4-vector of f32s.

Aliased Type§

struct FVec4(/* private fields */);

Implementations§

source§

impl FVec4

source

pub fn w(self) -> f32

The vector’s w component (also called r for the real component of ijk[r]).

source

pub fn from_raw(raw: C3D_FVec) -> Self

source

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

Create a new FVec4 from its components.

§Example
let v = FVec4::new(1.0, 2.0, 3.0, 4.0);
source

pub fn splat(v: f32) -> Self

Create a new FVec4, setting each component to v.

§Example
let v = FVec4::splat(1.0);
assert_abs_diff_eq!(v, FVec4::new(1.0, 1.0, 1.0, 1.0));
source

pub fn perspective_divide(self) -> Self

Divide the vector’s XYZ components by its W component.

§Example
let v = FVec4::new(2.0, 4.0, 6.0, 2.0);
assert_abs_diff_eq!(v.perspective_divide(), FVec4::new(1.0, 2.0, 3.0, 1.0));
source

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

The dot product of two vectors.

§Example
let v1 = FVec4::new(1.0, 2.0, 3.0, 4.0);
let v2 = FVec4::new(1.0, 0.5, 1.0, 0.5);
assert_abs_diff_eq!(v1.dot(v2), 7.0);
source

pub fn magnitude(self) -> f32

The magnitude of the vector.

§Example
let v = FVec4::splat(1.0);
assert_abs_diff_eq!(v.magnitude(), 2.0);
source

pub fn normalize(self) -> Self

Normalize the vector to a magnitude of 1.0.

§Example
let v = FVec4::new(1.0, 2.0, 2.0, 4.0);
assert_abs_diff_eq!(v.normalize(), FVec4::new(0.2, 0.4, 0.4, 0.8));
source§

impl<const N: usize> FVec<N>

source

pub fn x(self) -> f32

The vector’s x component (also called the i component of ijk[r]).

source

pub fn y(self) -> f32

The vector’s y component (also called the j component of ijk[r]).

source

pub fn z(self) -> f32

The vector’s i component (also called the k component of ijk[r]).

Trait Implementations§

source§

impl Add for FVec4

§

type Output = FVec<4>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl From<Vec4> for FVec4

Available on crate feature glam only.
source§

fn from(value: Vec4) -> Self

Converts to this type from the input type.
source§

impl Mul<f32> for FVec4

§

type Output = FVec<4>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Neg for FVec4

§

type Output = FVec<4>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Sub for FVec4

§

type Output = FVec<4>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<const N: usize> Clone for FVec<N>

source§

fn clone(&self) -> FVec<N>

Returns a copy of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
source§

impl<const N: usize> Debug for FVec<N>

source§

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

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

impl<const N: usize> Div<f32> for FVec<N>
where FVec<N>: Mul<f32>,

§

type Output = <FVec<N> as Mul<f32>>::Output

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<const N: usize> PartialEq for FVec<N>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0§

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

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

impl<const N: usize> Copy for FVec<N>

source§

impl<const N: usize> Eq for FVec<N>