Type Alias Vec3
Source pub type Vec3<T = f32> = Vector<T, 3>;
Expand description
pub struct Vec3<T = f32>();
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]);
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]);
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]);
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]);