Platformer in OpenGL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/gtc/quaternion.hpp>
  3. #include <glm/gtx/matrix_interpolation.hpp>
  4. #include <iostream>
  5. int test_axisAngle()
  6. {
  7. int Error = 0;
  8. glm::mat4 m1(-0.9946f, 0.0f, -0.104531f, 0.0f,
  9. 0.0f, 1.0f, 0.0f, 0.0f,
  10. 0.104531f, 0.0f, -0.9946f, 0.0f,
  11. 0.0f, 0.0f, 0.0f, 1.0f);
  12. glm::mat4 m2(-0.992624f, 0.0f, -0.121874f, 0.0f,
  13. 0.0f, 1.0f, 0.0f, 0.0f,
  14. 0.121874f, 0.0f, -0.992624f, 0.0f,
  15. 0.0f, 0.0f, 0.0f, 1.0f);
  16. glm::mat4 const m1rot = glm::extractMatrixRotation(m1);
  17. glm::mat4 const dltRotation = m2 * glm::transpose(m1rot);
  18. glm::vec3 dltAxis(0.0f);
  19. float dltAngle = 0.0f;
  20. glm::axisAngle(dltRotation, dltAxis, dltAngle);
  21. std::cout << "dltAxis: (" << dltAxis.x << ", " << dltAxis.y << ", " << dltAxis.z << "), dltAngle: " << dltAngle << std::endl;
  22. glm::quat q = glm::quat_cast(dltRotation);
  23. std::cout << "q: (" << q.x << ", " << q.y << ", " << q.z << ", " << q.w << ")" << std::endl;
  24. float yaw = glm::yaw(q);
  25. std::cout << "Yaw: " << yaw << std::endl;
  26. return Error;
  27. }
  28. int main()
  29. {
  30. int Error = 0;
  31. Error += test_axisAngle();
  32. return Error;
  33. }