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.

61 lines
1.5 KiB

5 years ago
  1. #include <glm/ext/vector_float3.hpp>
  2. #include <glm/ext/quaternion_common.hpp>
  3. #include <glm/ext/quaternion_float.hpp>
  4. #include <glm/ext/quaternion_relational.hpp>
  5. #include <glm/ext/quaternion_trigonometric.hpp>
  6. #include <glm/ext/scalar_constants.hpp>
  7. #include <glm/ext/scalar_relational.hpp>
  8. static int test_conjugate()
  9. {
  10. int Error = 0;
  11. glm::quat const A(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
  12. glm::quat const C = glm::conjugate(A);
  13. Error += glm::any(glm::notEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
  14. glm::quat const B = glm::conjugate(C);
  15. Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
  16. return Error;
  17. }
  18. static int test_mix()
  19. {
  20. int Error = 0;
  21. glm::quat const Q1(glm::vec3(1, 0, 0), glm::vec3(1, 0, 0));
  22. glm::quat const Q2(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
  23. {
  24. glm::quat const Q3 = glm::mix(Q1, Q2, 0.5f);
  25. float const F3 = glm::degrees(glm::angle(Q3));
  26. Error += glm::equal(F3, 45.0f, 0.001f) ? 0 : 1;
  27. glm::quat const Q4 = glm::mix(Q2, Q1, 0.5f);
  28. float const F4 = glm::degrees(glm::angle(Q4));
  29. Error += glm::equal(F4, 45.0f, 0.001f) ? 0 : 1;
  30. }
  31. {
  32. glm::quat const Q3 = glm::slerp(Q1, Q2, 0.5f);
  33. float const F3 = glm::degrees(glm::angle(Q3));
  34. Error += glm::equal(F3, 45.0f, 0.001f) ? 0 : 1;
  35. glm::quat const Q4 = glm::slerp(Q2, Q1, 0.5f);
  36. float const F4 = glm::degrees(glm::angle(Q4));
  37. Error += glm::equal(F4, 45.0f, 0.001f) ? 0 : 1;
  38. }
  39. return Error;
  40. }
  41. int main()
  42. {
  43. int Error = 0;
  44. Error += test_conjugate();
  45. Error += test_mix();
  46. return Error;
  47. }