dsalgo/vector_rotation_matrix_2d.rs
1pub fn rotation_matrix(radian: f64) -> [[f64; 2]; 2] {
2 let s = radian.sin();
3
4 let c = radian.cos();
5
6 [[c, -s], [s, c]]
7}
8
9#[cfg(test)]
10
11mod tests {
12
13 use super::*;
14
15 #[test]
16
17 fn test() {
18 use std::f64::consts::PI;
19
20 let rad = PI / 2.;
21
22 dbg!(rotation_matrix(rad));
23
24 dbg!(rotation_matrix(-rad));
25 }
26}