use crate::ops::{Isometry3, Rotation3, Translation3};
use qtty::Unit;
pub trait ComposeAfter<Prev> {
type Output;
fn after(self, prev: Prev) -> Self::Output;
}
impl ComposeAfter<Rotation3> for Rotation3 {
type Output = Rotation3;
#[inline]
fn after(self, prev: Rotation3) -> Rotation3 {
self.compose(&prev)
}
}
impl<U: Unit> ComposeAfter<Translation3<U>> for Translation3<U> {
type Output = Translation3<U>;
#[inline]
fn after(self, prev: Translation3<U>) -> Translation3<U> {
self.compose(&prev)
}
}
impl<U: Unit> ComposeAfter<Isometry3<U>> for Isometry3<U> {
type Output = Isometry3<U>;
#[inline]
fn after(self, prev: Isometry3<U>) -> Isometry3<U> {
self.compose(&prev)
}
}
impl<U: Unit> ComposeAfter<Rotation3> for Translation3<U> {
type Output = Isometry3<U>;
#[inline]
fn after(self, prev: Rotation3) -> Isometry3<U> {
Isometry3::new(prev, self)
}
}
impl<U: Unit> ComposeAfter<Translation3<U>> for Rotation3 {
type Output = Isometry3<U>;
#[inline]
fn after(self, prev: Translation3<U>) -> Isometry3<U> {
let rotated_t = self.apply_array(prev.v);
Isometry3::new(self, Translation3::from_array(rotated_t))
}
}
impl<U: Unit> ComposeAfter<Rotation3> for Isometry3<U> {
type Output = Isometry3<U>;
#[inline]
fn after(self, prev: Rotation3) -> Isometry3<U> {
self.compose(&Isometry3::from_rotation(prev))
}
}
impl<U: Unit> ComposeAfter<Isometry3<U>> for Rotation3 {
type Output = Isometry3<U>;
#[inline]
fn after(self, prev: Isometry3<U>) -> Isometry3<U> {
Isometry3::from_rotation(self).compose(&prev)
}
}
impl<U: Unit> ComposeAfter<Translation3<U>> for Isometry3<U> {
type Output = Isometry3<U>;
#[inline]
fn after(self, prev: Translation3<U>) -> Isometry3<U> {
self.compose(&Isometry3::from_translation(prev))
}
}
impl<U: Unit> ComposeAfter<Isometry3<U>> for Translation3<U> {
type Output = Isometry3<U>;
#[inline]
fn after(self, prev: Isometry3<U>) -> Isometry3<U> {
Isometry3::from_translation(self).compose(&prev)
}
}