Type Alias munum::Vec4

source ·
pub type Vec4<T = f32> = Vector<T, 4>;
Expand description

A 4D vector

Aliased Type§

struct Vec4<T = f32>(/* private fields */);

Implementations§

source§

impl<T: Copy + NumAssign> Vec4<T>

source

pub fn from_vec3(v: Vec3<T>, w: T) -> Self

Creates a new Vec4 from a Vec3 and w component.

§Examples
let v = Vec3::<i32>::from_slice(&[2, 3, 4]);
assert_eq!(*Vec4::<i32>::from_vec3(v, 1).as_ref(), [2, 3, 4, 1]);
source

pub fn xy(&self) -> Vec2<T>

Returns a copy of the xy components as a Vec2.

§Examples
let v = Vec4::<i32>::from_slice(&[1, 2, 3, 4]);
assert_eq!(*v.xy().as_ref(), [1, 2]);
source

pub fn xyz(&self) -> Vec3<T>

Returns a copy of the xyz components as a Vec3.

§Examples
let v = Vec4::<i32>::from_slice(&[1, 2, 3, 4]);
assert_eq!(*v.xyz().as_ref(), [1, 2, 3]);

Trait Implementations§

source§

impl<T: Copy + NumAssign> From<Matrix<T, 3, 1>> for Vec4<T>

source§

fn from(v: Vec3<T>) -> Self

Augments a Vec3 into a Vec4 The resulting Vec4 contains the given Vec3 with w = 1.

§Examples
let v = Vec4::from(Vec3::<i32>::from_slice(&[2, 3, 4]));
assert_eq!(*v.as_ref(), [2, 3, 4, 1]);