Type Definition munum::Vec3

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

A 3D vector

Implementations

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

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

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

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