Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Matrix3 ComputeJacobiRotation(const Matrix3& matrix)
  2. {
  3. /******Student:Assignment2******/
  4. float z = matrix[0][1], y = matrix[0][2], x = matrix[1][2];
  5. int max = 0;
  6. if (Math::Abs(z) > Math::Abs(x) && Math::Abs(z) > Math::Abs(y))
  7. max = 2;
  8. else if (Math::Abs(y) > Math::Abs(x) && Math::Abs(y) > Math::Abs(z))
  9. max = 1;
  10. Matrix3 ret;
  11. ret.SetIdentity();
  12. float theta;
  13. switch (max)
  14. {
  15. case 0:
  16. theta = Math::ArcTan((2 * x) / (matrix[1][1] - matrix[2][2])) / 2.0f;
  17. ret[1][1] = cos(theta);
  18. ret[1][2] = -sin(theta);
  19. ret[2][1] = sin(theta);
  20. ret[2][2] = cos(theta);
  21. break;
  22. case 1:
  23. theta = Math::ArcTan((2 * y) / (matrix[2][2] - matrix[0][0])) / 2.0f;
  24. ret[0][0] = cos(theta);
  25. ret[0][2] = sin(theta);
  26. ret[2][0] = -sin(theta);
  27. ret[2][2] = cos(theta);
  28. break;
  29. case 2:
  30. theta = Math::ArcTan((2 * z) / (matrix[0][0] - matrix[1][1])) / 2.0f;
  31. ret[0][0] = cos(theta);
  32. ret[0][1] = -sin(theta);
  33. ret[1][0] = sin(theta);
  34. ret[1][1] = cos(theta);
  35. break;
  36. }
  37.  
  38. return ret;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement