pub fn from_rotation_vector<T>(r: Vector3<T>) -> Quaternion<T>where
T: Float + FloatConst,Expand description
Converts a Rotation Vector into a Versor.
A Rotation Vector is a convenient representation where:
- Its direction defines the rotation axis.
- Its norm defines the rotation angle (in radians).
There are no particular restrictions on the norm of the input Rotation Vector. Also, even if a zero vector is input, the conversion to a Versor can be performed without falling into a singularity.
ยงExamples
let angle = PI / 2.0;
let axis = [1.0, 0.0, 0.0];
// This represents a rotation of pi/2 around the x-axis.
let rot_vec = scale(angle, axis); // Rotation vector
// Rotation vector ---> Quaternion
let q = from_rotation_vector(rot_vec);
let r = point_rotation(q, [1.0, 1.0, 0.0]);
assert!( (r[0] - 1.0).abs() < 1e-12 );
assert!( (r[1] - 0.0).abs() < 1e-12 );
assert!( (r[2] - 1.0).abs() < 1e-12 );