Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Matrix3 ComputeJacobiRotation(const Matrix3& matrix)
- {
- /******Student:Assignment2******/
- float z = matrix[0][1], y = matrix[0][2], x = matrix[1][2];
- int max = 0;
- if (Math::Abs(z) > Math::Abs(x) && Math::Abs(z) > Math::Abs(y))
- max = 2;
- else if (Math::Abs(y) > Math::Abs(x) && Math::Abs(y) > Math::Abs(z))
- max = 1;
- Matrix3 ret;
- ret.SetIdentity();
- float theta;
- switch (max)
- {
- case 0:
- theta = Math::ArcTan((2 * x) / (matrix[1][1] - matrix[2][2])) / 2.0f;
- ret[1][1] = cos(theta);
- ret[1][2] = -sin(theta);
- ret[2][1] = sin(theta);
- ret[2][2] = cos(theta);
- break;
- case 1:
- theta = Math::ArcTan((2 * y) / (matrix[2][2] - matrix[0][0])) / 2.0f;
- ret[0][0] = cos(theta);
- ret[0][2] = sin(theta);
- ret[2][0] = -sin(theta);
- ret[2][2] = cos(theta);
- break;
- case 2:
- theta = Math::ArcTan((2 * z) / (matrix[0][0] - matrix[1][1])) / 2.0f;
- ret[0][0] = cos(theta);
- ret[0][1] = -sin(theta);
- ret[1][0] = sin(theta);
- ret[1][1] = cos(theta);
- break;
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement