MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ create_rotation_matrix()

Eigen::MatrixXd MayaFlux::Kinesis::create_rotation_matrix ( double  angle,
uint32_t  axis = 2,
uint32_t  dimensions = 2 
)

Create N-dimensional rotation matrix.

Parameters
angleRotation angle in radians
axisRotation axis index (0=X, 1=Y, 2=Z). Only used when dimensions >= 3
dimensionsDimensionality of the rotation (2 or 3 supported directly, higher dimensions return identity)
Returns
Rotation matrix as Eigen::MatrixXd

Definition at line 5 of file MatrixTransforms.cpp.

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}

Referenced by create_rotation_scaling_matrix().

+ Here is the caller graph for this function: