Function from_axis_angle

Source
pub fn from_axis_angle<T>(axis: Vector3<T>, angle: T) -> Quaternion<T>
where T: Float + FloatConst,
Expand description

Generate Versor by specifying rotation angle[rad] and axis vector.

The axis vector does not have to be a unit vector.

If you enter a zero vector, it returns an identity quaternion.

ยงExamples

// Generates a quaternion representing the
// rotation of pi/2[rad] around the y-axis.
let q = from_axis_angle([0.0, 1.0, 0.0], PI/2.0);
 
// Rotate the point.
let r = point_rotation(q, [2.0, 2.0, 0.0]);
 
assert!( (r[0] - 0.0).abs() < 1e-12 );
assert!( (r[1] - 2.0).abs() < 1e-12 );
assert!( (r[2] + 2.0).abs() < 1e-12 );