2018-09-20 20:23:31 +08:00
|
|
|
use na::{self, Real, Unit, U4};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
|
|
|
use aliases::{Vec, Qua};
|
|
|
|
|
|
|
|
pub fn conjugate<N: Real>(q: &Qua<N>) -> Qua<N> {
|
2018-09-20 20:23:31 +08:00
|
|
|
q.conjugate()
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn inverse<N: Real>(q: &Qua<N>) -> Qua<N> {
|
2018-09-20 20:23:31 +08:00
|
|
|
q.try_inverse().unwrap_or(na::zero())
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-20 20:23:31 +08:00
|
|
|
//pub fn isinf<N: Real>(x: &Qua<N>) -> Vec<bool, U4> {
|
|
|
|
// x.coords.map(|e| e.is_inf())
|
|
|
|
//}
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-20 20:23:31 +08:00
|
|
|
//pub fn isnan<N: Real>(x: &Qua<N>) -> Vec<bool, U4> {
|
|
|
|
// x.coords.map(|e| e.is_nan())
|
|
|
|
//}
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-20 20:23:31 +08:00
|
|
|
pub fn lerp<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
|
|
|
|
x.lerp(y, a)
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-20 20:23:31 +08:00
|
|
|
pub fn mix<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
|
|
|
|
x * (N::one() - a) + y * a
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-20 20:23:31 +08:00
|
|
|
pub fn slerp<N: Real>(x: &Qua<N>, y: &Qua<N>, a: N) -> Qua<N> {
|
|
|
|
Unit::new_normalize(*x).slerp(&Unit::new_normalize(*y), a).unwrap()
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|