diff --git a/src/cgmath/matrix.rs b/src/cgmath/matrix.rs index f7a757c..b00ce26 100644 --- a/src/cgmath/matrix.rs +++ b/src/cgmath/matrix.rs @@ -15,6 +15,7 @@ //! Column major, square matrix types and traits. +use std::fmt; use std::num::{Zero, zero, One, one, cast, sqrt}; use angle::{Rad, sin, cos, sin_cos}; @@ -720,3 +721,30 @@ ToQuat for Mat3 { } } } + +impl + fmt::Show> fmt::Show for Mat2 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f.buf, "[[{}, {}], [{}, {}]]", + self.cr(0, 0), self.cr(0, 1), + self.cr(1, 0), self.cr(1, 1)) + } +} + +impl + fmt::Show> fmt::Show for Mat3 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f.buf, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]", + self.cr(0, 0), self.cr(0, 1), self.cr(0, 2), + self.cr(1, 0), self.cr(1, 1), self.cr(1, 2), + self.cr(2, 0), self.cr(2, 1), self.cr(2, 2)) + } +} + +impl + fmt::Show> fmt::Show for Mat4 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f.buf, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]", + self.cr(0, 0), self.cr(0, 1), self.cr(0, 2), self.cr(0, 3), + self.cr(1, 0), self.cr(1, 1), self.cr(1, 2), self.cr(1, 3), + self.cr(2, 0), self.cr(2, 1), self.cr(2, 2), self.cr(2, 3), + self.cr(3, 0), self.cr(3, 1), self.cr(3, 2), self.cr(3, 3)) + } +}