mod ball;
mod point;
mod transform;
pub use ball::*;
pub use point::*;
pub use transform::*;
pub trait MinkowskiSum<T> {
type Output;
fn minkowski_sum(&self, t: &T) -> Self::Output;
}
pub trait MinkowskiNegationIsIdentity: Copy {}
pub trait MinkowskiNegation {
fn minkowski_negation(&self) -> Self;
}
pub trait MinkowskiDifference<T> {
type Output;
fn minkowski_difference(&self, t: &T) -> Self::Output;
}
pub trait MinkowskiDifferenceLifetimed<'a, T: 'a> {
type Output: 'a;
fn minkowski_difference_lt(&'a self, t: &'a T) -> Self::Output;
}
impl<T: MinkowskiNegationIsIdentity> MinkowskiNegation for T {
fn minkowski_negation(&self) -> Self {
*self
}
}
impl<'l, A, B: 'l, C: 'l> MinkowskiDifferenceLifetimed<'l, B> for A
where
A: MinkowskiDifference<B, Output = C>,
{
type Output = C;
fn minkowski_difference_lt(&'_ self, t: &'l B) -> Self::Output {
MinkowskiDifference::minkowski_difference(self, t)
}
}
impl<T, U, V> MinkowskiDifference<U> for T
where
T: MinkowskiSum<U, Output = V>,
U: MinkowskiNegation,
{
type Output = V;
fn minkowski_difference(&self, t: &U) -> Self::Output {
self.minkowski_sum(&t.minkowski_negation())
}
}