use crate::core::utils::Quat;
pub const QUATERNIONS: [Quat; 12] = [
[0.0, 0.0, 0.0, 1.0], [0.0, 0.5257311121191336, 0.0, 0.8506508083520399], [-0.5, 0.16245984811645314, 0.0, 0.8506508083520399], [
-0.30901699437494745,
-0.42532540417602,
0.0,
0.8506508083520399,
], [
0.30901699437494745,
-0.42532540417602,
0.0,
0.8506508083520399,
], [0.5, 0.16245984811645314, 0.0, 0.8506508083520399], [0.0, -0.8506508083520399, 0.0, 0.5257311121191336], [
0.8090169943749475,
-0.2628655560595668,
0.0,
0.5257311121191336,
], [0.5, 0.6881909602355868, 0.0, 0.5257311121191336], [-0.5, 0.6881909602355868, 0.0, 0.5257311121191336], [
-0.8090169943749475,
-0.2628655560595668,
0.0,
0.5257311121191336,
], [0.0, -1.0, 0.0, 0.0], ];
#[cfg(test)]
mod tests {
use super::*;
const COS_ALPHA: f64 = 0.8506508083520399;
const SIN_ALPHA: f64 = 0.5257311121191336;
#[test]
fn test_quaternions_length() {
assert_eq!(QUATERNIONS.len(), 12);
}
#[test]
fn test_quaternions_normalized() {
for (i, q) in QUATERNIONS.iter().enumerate() {
let magnitude = (q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]).sqrt();
assert!(
(magnitude - 1.0).abs() < 1e-10,
"Quaternion {} is not normalized: magnitude = {}",
i,
magnitude
);
}
}
#[test]
fn test_north_pole_identity() {
assert_eq!(QUATERNIONS[0], [0.0, 0.0, 0.0, 1.0]);
}
#[test]
fn test_south_pole() {
assert_eq!(QUATERNIONS[11], [0.0, -1.0, 0.0, 0.0]);
}
#[test]
fn test_first_ring_structure() {
for q in QUATERNIONS.iter().take(6).skip(1) {
assert!((q[2] - 0.0).abs() < 1e-15);
assert!((q[3] - COS_ALPHA).abs() < 1e-10);
}
}
#[test]
fn test_second_ring_structure() {
for q in QUATERNIONS.iter().take(11).skip(6) {
assert!((q[2] - 0.0).abs() < 1e-15);
assert!((q[3] - SIN_ALPHA).abs() < 1e-10);
}
}
}