use super::{Point, Vector3};
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct CoordinateSystem {
pub right: Vector3,
pub up: Vector3,
pub ahead: Vector3,
pub origin: Point,
}
impl Default for CoordinateSystem {
fn default() -> Self {
Self {
right: Vector3::new(1.0, 0.0, 0.0),
up: Vector3::new(0.0, 1.0, 0.0),
ahead: Vector3::new(0.0, 0.0, 1.0),
origin: Vector3::new(0.0, 0.0, 0.0),
}
}
}
impl From<CoordinateSystem> for audionimbus_sys::IPLCoordinateSpace3 {
fn from(coordinate_system: CoordinateSystem) -> Self {
Self {
right: coordinate_system.right.into(),
up: coordinate_system.up.into(),
ahead: coordinate_system.ahead.into(),
origin: coordinate_system.origin.into(),
}
}
}
impl From<audionimbus_sys::IPLCoordinateSpace3> for CoordinateSystem {
fn from(coordinate_system: audionimbus_sys::IPLCoordinateSpace3) -> Self {
Self {
right: coordinate_system.right.into(),
up: coordinate_system.up.into(),
ahead: coordinate_system.ahead.into(),
origin: coordinate_system.origin.into(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_coordinate_system_default() {
let cs = CoordinateSystem::default();
assert_eq!(
cs,
CoordinateSystem {
right: Vector3::new(1.0, 0.0, 0.0),
up: Vector3::new(0.0, 1.0, 0.0),
ahead: Vector3::new(0.0, 0.0, 1.0),
origin: Vector3::new(0.0, 0.0, 0.0),
}
);
}
}