gtx_vector_query.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2011-11-23
  5. // Updated : 2011-11-23
  6. // Licence : This source is under MIT licence
  7. // File : test/gtx/vector_query.cpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. #define GLM_FORCE_RADIANS
  10. #include <glm/glm.hpp>
  11. #include <glm/gtx/vector_query.hpp>
  12. int test_areCollinear()
  13. {
  14. int Error(0);
  15. {
  16. bool TestA = glm::areCollinear(glm::vec2(-1), glm::vec2(1), 0.00001f);
  17. Error += TestA ? 0 : 1;
  18. }
  19. {
  20. bool TestA = glm::areCollinear(glm::vec3(-1), glm::vec3(1), 0.00001f);
  21. Error += TestA ? 0 : 1;
  22. }
  23. {
  24. bool TestA = glm::areCollinear(glm::vec4(-1), glm::vec4(1), 0.00001f);
  25. Error += TestA ? 0 : 1;
  26. }
  27. return Error;
  28. }
  29. int test_areOrthogonal()
  30. {
  31. int Error(0);
  32. bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
  33. Error += TestA ? 0 : 1;
  34. return Error;
  35. }
  36. int test_isNormalized()
  37. {
  38. int Error(0);
  39. bool TestA = glm::isNormalized(glm::vec4(1, 0, 0, 0), 0.00001f);
  40. Error += TestA ? 0 : 1;
  41. return Error;
  42. }
  43. int test_isNull()
  44. {
  45. int Error(0);
  46. bool TestA = glm::isNull(glm::vec4(0), 0.00001f);
  47. Error += TestA ? 0 : 1;
  48. return Error;
  49. }
  50. int test_areOrthonormal()
  51. {
  52. int Error(0);
  53. bool TestA = glm::areOrthonormal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
  54. Error += TestA ? 0 : 1;
  55. return Error;
  56. }
  57. int main()
  58. {
  59. int Error(0);
  60. Error += test_areCollinear();
  61. Error += test_areOrthogonal();
  62. Error += test_isNormalized();
  63. Error += test_isNull();
  64. Error += test_areOrthonormal();
  65. return Error;
  66. }