use core::ops::Neg;
use crate::{
common,
numeric::{IsZero, Negate, Zero},
quaternion::Quaternion,
};
impl<T> Quaternion<T>
where
T: Zero,
{
pub const ZERO: Self = Self::new(T::ZERO, T::ZERO, T::ZERO, T::ZERO);
}
impl<T> Zero for Quaternion<T>
where
T: Zero,
{
const ZERO: Self = Quaternion::ZERO;
}
impl<T> Quaternion<T>
where
T: Copy + Zero + PartialEq,
{
#[inline]
pub fn is_zero(self) -> bool {
self == Self::ZERO
}
}
impl<T> IsZero for Quaternion<T>
where
T: Copy + Zero + PartialEq,
{
#[inline]
fn is_zero(self) -> bool {
Quaternion::is_zero(self)
}
}
common::impl_tuple_wrapper_numeric_predicates!([T], Quaternion<T>, item: T, len: 4);
impl<T> Quaternion<T>
where
T: Copy + Neg<Output = T>,
{
#[inline]
pub fn negate(self) -> Self {
let out = self.into_tuple().negate();
Self::from_tuple(out)
}
}
impl<T> Negate for Quaternion<T>
where
T: Copy + Neg<Output = T>,
{
#[inline]
fn negate(self) -> Self::Output {
Quaternion::negate(self)
}
}