Skip to main content

ear_algae/
ops.rs

1pub trait Dot<T> {
2    type Output;
3
4    fn dot(self, other: T) -> Self::Output;
5}
6
7pub trait Cross<T = Self> {
8    type Output;
9
10    fn cross(self, other: T) -> Self::Output;
11}
12
13pub trait Apl<T> {
14    type Output;
15
16    fn apl(self, other: T) -> Self::Output;
17}
18
19pub trait BefAft: Sized + Copy {
20    fn aft(self, other: Self) -> Self;
21    fn bef(self, other: Self) -> Self {
22        other.aft(self)
23    }
24
25    fn aft_assign(&mut self, other: Self) {
26        *self = self.aft(other)
27    }
28    fn bef_assign(&mut self, other: Self) {
29        *self = self.bef(other)
30    }
31}
32
33pub trait ProjRej<A>: Sized {
34    type Output;
35    fn proj(self, axis: A) -> Self::Output;
36    fn rej(self, axis: A) -> Self::Output;
37    fn proj_rej(self, axis: A) -> (Self::Output, Self::Output);
38}
39
40pub trait Refl<A> {
41    type Output;
42    fn refl(self, axis: A) -> Self::Output;
43}
44
45pub trait AngleTo<T = Self> {
46    type Output;
47    fn angle_to(self, other: T) -> Self::Output;
48}
49
50pub trait Det {
51    type Output;
52    fn det(self) -> Self::Output;
53}
54
55pub trait Aplable<A> {
56    type Output;
57    fn apply(self, apler: A) -> Self::Output;
58}
59
60impl<A, T: Aplable<A>> Apl<T> for A {
61    type Output = <T as Aplable<A>>::Output;
62
63    fn apl(self, other: T) -> Self::Output {
64        other.apply(self)
65    }
66}