2018-09-20 16:50:34 +08:00
|
|
|
use na::Real;
|
|
|
|
|
|
|
|
use aliases::Qua;
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Multiplies two quaternions.
|
2018-09-22 22:40:58 +08:00
|
|
|
pub fn quat_cross<N: Real>(q1: &Qua<N>, q2: &Qua<N>) -> Qua<N> {
|
2018-09-20 20:23:31 +08:00
|
|
|
q1 * q2
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
2018-09-22 19:18:59 +08:00
|
|
|
|
|
|
|
/// The scalar product of two quaternions.
|
2018-09-22 22:40:58 +08:00
|
|
|
pub fn quat_dot<N: Real>(x: &Qua<N>, y: &Qua<N>) -> N {
|
2018-09-20 20:23:31 +08:00
|
|
|
x.dot(y)
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
2018-09-22 19:18:59 +08:00
|
|
|
|
|
|
|
/// The magnitude of the quaternion `q`.
|
2018-09-22 22:40:58 +08:00
|
|
|
pub fn quat_length<N: Real>(q: &Qua<N>) -> N {
|
2018-09-20 20:23:31 +08:00
|
|
|
q.norm()
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
2018-09-22 19:18:59 +08:00
|
|
|
|
|
|
|
/// The magnitude of the quaternion `q`.
|
2018-09-22 22:40:58 +08:00
|
|
|
pub fn quat_magnitude<N: Real>(q: &Qua<N>) -> N {
|
2018-09-22 19:18:59 +08:00
|
|
|
q.norm()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Normalizes the quaternion `q`.
|
2018-09-22 22:40:58 +08:00
|
|
|
pub fn quat_normalize<N: Real>(q: &Qua<N>) -> Qua<N> {
|
2018-09-20 20:23:31 +08:00
|
|
|
q.normalize()
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|