6{
7 if (dimensions == 2) {
8 Eigen::Matrix2d rotation;
9 rotation << std::cos(angle), -std::sin(angle),
10 std::sin(angle), std::cos(angle);
11 return rotation;
12 }
13
14 if (dimensions == 3) {
15 Eigen::Matrix3d rotation = Eigen::Matrix3d::Identity();
16
17 switch (axis) {
18 case 0:
19 rotation << 1, 0, 0,
20 0, std::cos(angle), -std::sin(angle),
21 0, std::sin(angle), std::cos(angle);
22 break;
23 case 1:
24 rotation << std::cos(angle), 0, std::sin(angle),
25 0, 1, 0,
26 -std::sin(angle), 0, std::cos(angle);
27 break;
28 case 2:
29 default:
30 rotation << std::cos(angle), -std::sin(angle), 0,
31 std::sin(angle), std::cos(angle), 0,
32 0, 0, 1;
33 break;
34 }
35 return rotation;
36 }
37
38 return Eigen::MatrixXd::Identity(dimensions, dimensions);
39}