Add Mat2::from_angle constructor
This commit is contained in:
parent
0325af9a69
commit
bd9f129b3a
1 changed files with 12 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue