2018-09-21 01:54:12 +08:00
|
|
|
use na::{Real, Unit, Rotation3, Matrix4, U3, U4};
|
|
|
|
|
|
|
|
use traits::Number;
|
|
|
|
use aliases::{Vec, Mat};
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in radians.
|
2018-09-21 01:54:12 +08:00
|
|
|
pub fn rotate<N: Real>(angle: N, v: &Vec<N, U3>) -> Mat<N, U4, U4> {
|
|
|
|
Rotation3::from_axis_angle(&Unit::new_normalize(*v), angle).to_homogeneous()
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components.
|
2018-09-21 01:54:12 +08:00
|
|
|
pub fn scale<N: Number>(v: &Vec<N, U3>) -> Mat<N, U4, U4> {
|
|
|
|
Matrix4::new_nonuniform_scaling(v)
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars.
|
2018-09-21 01:54:12 +08:00
|
|
|
pub fn translate<N: Number>(v: &Vec<N, U3>) -> Mat<N, U4, U4> {
|
|
|
|
Matrix4::new_translation(v)
|
|
|
|
}
|