dimforge / nalgebra

Linear algebra library for Rust.
https://nalgebra.org
Apache License 2.0
4.05k stars 485 forks source link

`UnitQuaternion` doesn't guarantee it's a unit quaternion #1438

Open powei-lin opened 2 months ago

powei-lin commented 2 months ago
use nalgebra as na;

fn main() {
    let q = na::UnitQuaternion::from_quaternion(na::Quaternion::new(0.2, 0.3, 0.4, 0.5));
    println!("q len {}", q.norm());
    let mut a = q.clone();
    for _ in 0..50{
        a *= a;
    }
    println!("a len {}", a.norm());
}
q len 0.9999999999999999
a len 0.9930460900296578

Which is a huge problem when doing robotics.