2019-03-25 18:21:41 +08:00
|
|
|
use na::RealField;
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::aliases::Qua;
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Multiplies two quaternions.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn quat_cross<T: RealField>(q1: &Qua<T>, q2: &Qua<T>) -> Qua<T> {
|
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.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn quat_dot<T: RealField>(x: &Qua<T>, y: &Qua<T>) -> T {
|
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`.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn quat_length<T: RealField>(q: &Qua<T>) -> T {
|
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`.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn quat_magnitude<T: RealField>(q: &Qua<T>) -> T {
|
2018-09-22 19:18:59 +08:00
|
|
|
q.norm()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Normalizes the quaternion `q`.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn quat_normalize<T: RealField>(q: &Qua<T>) -> Qua<T> {
|
2018-09-20 20:23:31 +08:00
|
|
|
q.normalize()
|
2018-10-22 04:11:27 +08:00
|
|
|
}
|