use crate::{CoordinateFrameType, EastNorthUp, NorthEastDown};
pub trait CoordinateFrame {
type Type;
const COORDINATE_FRAME: CoordinateFrameType;
fn coordinate_frame(&self) -> CoordinateFrameType;
fn to_ned(&self) -> NorthEastDown<Self::Type>
where
Self::Type: Copy + SaturatingNeg<Output = Self::Type>;
fn to_enu(&self) -> EastNorthUp<Self::Type>
where
Self::Type: Copy + SaturatingNeg<Output = Self::Type>;
fn x(&self) -> Self::Type
where
Self::Type: Clone;
fn y(&self) -> Self::Type
where
Self::Type: Clone;
fn z(&self) -> Self::Type
where
Self::Type: Clone;
fn x_ref(&self) -> &Self::Type;
fn y_ref(&self) -> &Self::Type;
fn z_ref(&self) -> &Self::Type;
fn x_mut(&mut self) -> &mut Self::Type;
fn y_mut(&mut self) -> &mut Self::Type;
fn z_mut(&mut self) -> &mut Self::Type;
fn right_handed(&self) -> bool;
fn x_axis() -> [Self::Type; 3]
where
Self::Type: ZeroOne<Output = Self::Type> + core::ops::Neg<Output = Self::Type>;
fn y_axis() -> [Self::Type; 3]
where
Self::Type: ZeroOne<Output = Self::Type> + core::ops::Neg<Output = Self::Type>;
fn z_axis() -> [Self::Type; 3]
where
Self::Type: ZeroOne<Output = Self::Type> + core::ops::Neg<Output = Self::Type>;
}
pub trait RightHanded {}
pub trait LeftHanded {}
pub trait ZeroOne {
type Output;
fn zero() -> Self::Output;
fn one() -> Self::Output;
}
pub trait SaturatingNeg {
type Output;
fn saturating_neg(self) -> Self::Output;
}
impl SaturatingNeg for i8 {
type Output = Self;
fn saturating_neg(self) -> Self {
self.saturating_neg()
}
}
impl SaturatingNeg for i16 {
type Output = Self;
fn saturating_neg(self) -> Self {
self.saturating_neg()
}
}
impl SaturatingNeg for i32 {
type Output = Self;
fn saturating_neg(self) -> Self {
self.saturating_neg()
}
}
impl SaturatingNeg for i64 {
type Output = Self;
fn saturating_neg(self) -> Self {
self.saturating_neg()
}
}
impl SaturatingNeg for i128 {
type Output = Self;
fn saturating_neg(self) -> Self {
self.saturating_neg()
}
}
impl SaturatingNeg for f32 {
type Output = Self;
fn saturating_neg(self) -> Self {
-self
}
}
impl SaturatingNeg for f64 {
type Output = Self;
fn saturating_neg(self) -> Self {
-self
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for u8 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for i8 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for u16 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for i16 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for u32 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for i32 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for u64 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for i64 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for u128 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for i128 {
type Output = Self;
fn zero() -> Self::Output {
0
}
fn one() -> Self::Output {
1
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for f32 {
type Output = Self;
fn zero() -> Self::Output {
0.0
}
fn one() -> Self::Output {
1.0
}
}
#[cfg(not(feature = "num-traits"))]
impl ZeroOne for f64 {
type Output = Self;
fn zero() -> Self::Output {
0.0
}
fn one() -> Self::Output {
1.0
}
}
#[cfg(feature = "num-traits")]
impl<T> ZeroOne for T
where
T: num_traits::Zero + num_traits::One,
{
type Output = T;
fn zero() -> Self::Output {
<T as num_traits::Zero>::zero()
}
fn one() -> Self::Output {
<T as num_traits::One>::one()
}
}