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));

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