rgeometry/data/point/
sub.rsuse array_init::array_init;
use std::ops::Index;
use std::ops::Sub;
use super::Point;
use super::Vector;
impl<'a, 'b, T, const N: usize> Sub<&'a Point<T, N>> for &'b Point<T, N>
where
T: Sub<T, Output = T> + Clone,
{
type Output = Vector<T, N>;
fn sub(self: &'b Point<T, N>, other: &'a Point<T, N>) -> Self::Output {
Vector(array_init(|i| {
self.array.index(i).clone() - other.array.index(i).clone()
}))
}
}
impl<T, const N: usize> Sub<Point<T, N>> for Point<T, N>
where
T: Sub<T, Output = T> + Clone,
{
type Output = Vector<T, N>;
fn sub(self: Point<T, N>, other: Point<T, N>) -> Self::Output {
Sub::sub(&self, &other)
}
}