diff --git a/src/matrix.rs b/src/matrix.rs index 6687157..1f12ee6 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -756,6 +756,33 @@ impl ApproxEq for Matrix4 { } } +impl Transform> for Matrix3 { + fn one() -> Matrix3 { + One::one() + } + + fn look_at(eye: Point3, center: Point3, up: Vector3) -> Matrix3 { + let dir = center - eye; + Matrix3::look_at(dir, up) + } + + fn transform_vector(&self, vec: Vector3) -> Vector3 { + self * vec + } + + fn transform_point(&self, point: Point3) -> Point3 { + Point3::from_vec(self * point.to_vec()) + } + + fn concat(&self, other: &Matrix3) -> Matrix3 { + self * other + } + + fn invert(&self) -> Option> { + SquareMatrix::invert(self) + } +} + impl Transform> for Matrix4 { fn one() -> Matrix4 { One::one() @@ -782,6 +809,8 @@ impl Transform> for Matrix4 { } } +impl Transform3 for Matrix3 {} + impl Transform3 for Matrix4 {} macro_rules! impl_operators {