From bd9f129b3a6bc15d71698f5116f14b6d6b6b626f Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 3 Sep 2013 18:03:18 +1000 Subject: [PATCH] Add Mat2::from_angle constructor --- src/cgmath/matrix.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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,