rgeometry/data/point/
sub.rs1use array_init::array_init;
2use std::ops::Index;
3use std::ops::Sub;
4
5use super::Point;
6use super::Vector;
7
8impl<'a, 'b, T, const N: usize> Sub<&'a Point<T, N>> for &'b Point<T, N>
12where
13 T: Sub<T, Output = T> + Clone,
14{
15 type Output = Vector<T, N>;
16
17 fn sub(self: &'b Point<T, N>, other: &'a Point<T, N>) -> Self::Output {
18 Vector(array_init(|i| {
20 self.array.index(i).clone() - other.array.index(i).clone()
21 }))
22 }
23}
24
25impl<T, const N: usize> Sub<Point<T, N>> for Point<T, N>
26where
27 T: Sub<T, Output = T> + Clone,
28{
29 type Output = Vector<T, N>;
30
31 fn sub(self: Point<T, N>, other: Point<T, N>) -> Self::Output {
32 Sub::sub(&self, &other)
33 }
34}