ear_algae/rotor/
cross_product.rs1use crate::{Vect, ops::Cross, traits::Field};
2
3impl<S: Field> Cross for Vect<2, S> {
4 type Output = Vect<1, S>;
5
6 fn cross(self, other: Self) -> Vect<1, S> {
7 Vect([self[0].mul(other[1]).sub(other[0].mul(self[1]))])
8 }
9}
10
11impl<S: Field> Cross for Vect<3, S> {
12 type Output = Vect<3, S>;
13
14 fn cross(self, other: Self) -> Vect<3, S> {
15 Vect([
16 self[1].mul(other[2]).sub(other[1].mul(self[2])),
17 self[2].mul(other[0]).sub(other[2].mul(self[0])),
18 self[0].mul(other[1]).sub(other[0].mul(self[1])),
19 ])
20 }
21}