Function normalize

Source
pub fn normalize<T, U>(a: U) -> U
where T: Float, U: QuaternionOps<T>,
Expand description

Normalization of Vector3 or Quaternion.

ยงExamples

// --- Vector3 --- //
// This norm is not 1.
let v: Vector3<f64> = [1.0, 2.0, 3.0];
assert!( (1.0 - norm(v)).abs() > 1e-12 );
 
// Now that normalized, this norm is 1!
let v_n = normalize(v);
assert!( (1.0 - norm(v_n)).abs() < 1e-12 );
 
// --- Quaternion --- //
// This norm is not 1.
let q: Quaternion<f64> = (1.0, [2.0, 3.0, 4.0]);
assert!( (1.0 - norm(q)).abs() > 1e-12 );
 
// Now that normalized, this norm is 1!
let q_n = normalize(q);
assert!( (1.0 - norm(q_n)).abs() < 1e-12 );