1use vecmat::{Transform, transform::Directional, traits::Normalize};
2
3pub trait Map<P, D = P>: Clone {
4 fn identity() -> Self;
5
6 fn apply_pos(&self, pos: P) -> P;
7 fn apply_dir(&self, pos: P, dir: D) -> D;
8 fn apply_normal(&self, pos: P, normal: D) -> D;
9
10 fn chain(self, other: Self) -> Self;
11 fn inv(self) -> Self;
12}
13
14impl<A, T> Map<T, T> for A where A: Directional<T> + Clone, T: Normalize {
15 fn identity() -> Self {
16 <A as Transform<T>>::identity()
17 }
18
19 fn apply_pos(&self, pos: T) -> T {
20 <A as Transform<T>>::apply(self, pos)
21 }
22 fn apply_dir(&self, pos: T, dir: T) -> T {
23 <A as Directional<T>>::apply_dir(self, pos, dir)
24 }
25 fn apply_normal(&self, pos: T, dir: T) -> T {
26 <A as Directional<T>>::apply_normal(self, pos, dir)
27 }
28
29 fn chain(self, other: Self) -> Self {
30 <A as Transform<T>>::chain(self, other)
31 }
32 fn inv(self) -> Self {
33 <A as Transform<T>>::inv(self)
34 }
35}