1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use na::{Real, Unit, Rotation2, Rotation3};
use traits::Number;
use aliases::{TVec3, TVec2, TMat3, TMat4};
pub fn rotation<N: Real>(angle: N, v: &TVec3<N>) -> TMat4<N> {
Rotation3::from_axis_angle(&Unit::new_normalize(*v), angle).to_homogeneous()
}
pub fn scaling<N: Number>(v: &TVec3<N>) -> TMat4<N> {
TMat4::new_nonuniform_scaling(v)
}
pub fn translation<N: Number>(v: &TVec3<N>) -> TMat4<N> {
TMat4::new_translation(v)
}
pub fn rotation2d<N: Real>(angle: N) -> TMat3<N> {
Rotation2::new(angle).to_homogeneous()
}
pub fn scaling2d<N: Number>(v: &TVec2<N>) -> TMat3<N> {
TMat3::new_nonuniform_scaling(v)
}
pub fn translation2d<N: Number>(v: &TVec2<N>) -> TMat3<N> {
TMat3::new_translation(v)
}