Add Mat2::from_angle constructor

This commit is contained in:
Brendan Zabarauskas 2013-09-03 18:03:18 +10:00
parent 0325af9a69
commit bd9f129b3a

View file

@ -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<S: Clone + Num> Mat2<S> {
}
}
impl<S: Clone + Float> Mat2<S> {
#[inline]
pub fn from_angle(radians: S) -> Mat2<S> {
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<S: Clone + Num> Mat3<S> {
#[inline]
pub fn new(c0r0:S, c0r1:S, c0r2:S,