Function frame_rotation

Source
pub fn frame_rotation<T>(q: Quaternion<T>, v: Vector3<T>) -> Vector3<T>
where T: Float,
Expand description

Frame rotation by quaternion (Frame Rotation - Point Fixed)

q* v q (||q|| = 1)

Since it is implemented with an optimized formula, it can be calculated with the amount of operations shown in the table below:

OperationNum
Multiply18
Add/Subtract12

ยงExamples

// Make these as you like.
let v = [1.0, 0.5, -8.0];
let q = from_axis_angle([0.2, 1.0, -2.0], PI);
 
let r = point_rotation(q, v);
 
// This makes a lot of wasted calculations.
let r_check = mul( mul(conj(q), (0.0, v)), q ).1;
 
assert!( (r[0] - r_check[0]).abs() < 1e-12 );
assert!( (r[1] - r_check[1]).abs() < 1e-12 );
assert!( (r[2] - r_check[2]).abs() < 1e-12 );