Type Alias munum::Vec3

source ·
pub type Vec3<T = f32> = Vector<T, 3>;
Expand description

A 3D vector

Aliased Type§

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

Implementations§

source§

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

source

pub fn from_vec2(v: Vec2<T>, z: T) -> Self

Creates a new Vec3 from a Vec2 and z component.

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

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

Returns a copy of the xy components as a Vec2.

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

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

source

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

Calculates the cross product of this vector with another vector.

§Examples
let (v1, v2) = (Vec3::<i32>::from_slice(&[2, 3, 4]), Vec3::<i32>::from_slice(&[5, 6, 7]));
assert_eq!(*v1.cross(v2).as_ref(), [-3, 6, -3]);

Trait Implementations§

source§

impl<T: Copy + NumAssign> From<Matrix<T, 2, 1>> for Vec3<T>

source§

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

Augments a Vec2 into a Vec3 The resulting Vec3 contains the given Vec2 with z = 1.

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

impl<T: Copy + NumAssign> From<Matrix<T, 4, 1>> for Vec3<T>

source§

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

Creates a Vec3 from the (x, y, z) of a Vec4

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

impl<T: Copy + NumAssign> From<Quaternion<T>> for Vec3<T>

source§

fn from(q: Quaternion<T>) -> Self

Creates a Vec3 from a Quaternion by dropping the w component.

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