diff --git a/src/cgmath/matrix.rs b/src/cgmath/matrix.rs index 6a2096f..c5d2cdb 100644 --- a/src/cgmath/matrix.rs +++ b/src/cgmath/matrix.rs @@ -15,7 +15,7 @@ //! Column major, square matrix types and traits. -use std::num::{one, zero}; +use std::num::{one, zero, sin, cos}; use array::*; use quaternion::{Quat, ToQuat}; @@ -69,6 +69,17 @@ impl Mat2 { } } +impl Mat2 { + #[inline] + pub fn from_angle(radians: S) -> Mat2 { + let cos_theta = cos(radians.clone()); + let sin_theta = sin(radians.clone()); + + Mat2::new(cos_theta.clone(), -sin_theta.clone(), + sin_theta.clone(), cos_theta.clone()) + } +} + impl Mat3 { #[inline] pub fn new(c0r0:S, c0r1:S, c0r2:S,