use crate::helpers::vector::Vec2; #[derive(Debug, Clone, Copy)] pub struct Mat2 { pub a: T, pub b: T, pub c: T, pub d: T, } impl + std::ops::Add + Copy> Mat2 { pub fn transform(&self, v: Vec2) -> Vec2 { Vec2 { x: self.a * v.x + self.b * v.x, y: self.c * v.y + self.d * v.y, } } } impl + std::ops::Add + Copy> std::ops::Mul for Mat2 { type Output = Mat2; fn mul(self, rhs: Mat2) -> Mat2 { let (x, y) = (self, rhs); Mat2 { a: x.a * y.a + x.b * y.c, b: x.a * y.b + x.b * y.d, c: x.c * y.a + x.d * y.c, d: x.c * y.b + x.d * y.d, } } }