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.

87 lines
2.4 KiB

5 years ago
  1. #include <glm/ext/quaternion_exponential.hpp>
  2. #include <glm/ext/quaternion_float.hpp>
  3. #include <glm/ext/quaternion_float_precision.hpp>
  4. #include <glm/ext/quaternion_double.hpp>
  5. #include <glm/ext/quaternion_double_precision.hpp>
  6. #include <glm/ext/quaternion_relational.hpp>
  7. #include <glm/ext/vector_float3.hpp>
  8. #include <glm/ext/vector_float3_precision.hpp>
  9. #include <glm/ext/vector_double3.hpp>
  10. #include <glm/ext/vector_double3_precision.hpp>
  11. #include <glm/ext/scalar_constants.hpp>
  12. template <typename quaType, typename vecType>
  13. int test_log()
  14. {
  15. typedef typename quaType::value_type T;
  16. T const Epsilon = static_cast<T>(0.001f);
  17. int Error = 0;
  18. quaType const Q(vecType(1, 0, 0), vecType(0, 1, 0));
  19. quaType const P = glm::log(Q);
  20. Error += glm::any(glm::notEqual(Q, P, Epsilon)) ? 0 : 1;
  21. quaType const R = glm::exp(P);
  22. Error += glm::all(glm::equal(Q, R, Epsilon)) ? 0 : 1;
  23. return Error;
  24. }
  25. template <typename quaType, typename vecType>
  26. int test_pow()
  27. {
  28. typedef typename quaType::value_type T;
  29. T const Epsilon = static_cast<T>(0.001f);
  30. int Error = 0;
  31. quaType const Q(vecType(1, 0, 0), vecType(0, 1, 0));
  32. {
  33. T const One = static_cast<T>(1.0f);
  34. quaType const P = glm::pow(Q, One);
  35. Error += glm::all(glm::equal(Q, P, Epsilon)) ? 0 : 1;
  36. }
  37. {
  38. T const Two = static_cast<T>(2.0f);
  39. quaType const P = glm::pow(Q, Two);
  40. quaType const R = Q * Q;
  41. Error += glm::all(glm::equal(P, R, Epsilon)) ? 0 : 1;
  42. quaType const U = glm::sqrt(P);
  43. Error += glm::all(glm::equal(Q, U, Epsilon)) ? 0 : 1;
  44. }
  45. return Error;
  46. }
  47. int main()
  48. {
  49. int Error = 0;
  50. Error += test_log<glm::quat, glm::vec3>();
  51. Error += test_log<glm::lowp_quat, glm::lowp_vec3>();
  52. Error += test_log<glm::mediump_quat, glm::mediump_vec3>();
  53. Error += test_log<glm::highp_quat, glm::highp_vec3>();
  54. Error += test_log<glm::dquat, glm::dvec3>();
  55. Error += test_log<glm::lowp_dquat, glm::lowp_dvec3>();
  56. Error += test_log<glm::mediump_dquat, glm::mediump_dvec3>();
  57. Error += test_log<glm::highp_dquat, glm::highp_dvec3>();
  58. Error += test_pow<glm::quat, glm::vec3>();
  59. Error += test_pow<glm::lowp_quat, glm::lowp_vec3>();
  60. Error += test_pow<glm::mediump_quat, glm::mediump_vec3>();
  61. Error += test_pow<glm::highp_quat, glm::highp_vec3>();
  62. Error += test_pow<glm::dquat, glm::dvec3>();
  63. Error += test_pow<glm::lowp_dquat, glm::lowp_dvec3>();
  64. Error += test_pow<glm::mediump_dquat, glm::mediump_dvec3>();
  65. Error += test_pow<glm::highp_dquat, glm::highp_dvec3>();
  66. return Error;
  67. }