gtx_vector_query.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2012 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. #include <glm/glm.hpp>
  10. #include <glm/gtx/vector_query.hpp>
  11. int test_areCollinear()
  12. {
  13. int Error(0);
  14. {
  15. bool TestA = glm::areCollinear(glm::vec2(-1), glm::vec2(1), 0.00001f);
  16. Error += TestA ? 0 : 1;
  17. }
  18. {
  19. bool TestA = glm::areCollinear(glm::vec3(-1), glm::vec3(1), 0.00001f);
  20. Error += TestA ? 0 : 1;
  21. }
  22. {
  23. bool TestA = glm::areCollinear(glm::vec4(-1), glm::vec4(1), 0.00001f);
  24. Error += TestA ? 0 : 1;
  25. }
  26. return Error;
  27. }
  28. int test_areOrthogonal()
  29. {
  30. int Error(0);
  31. bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
  32. Error += TestA ? 0 : 1;
  33. return Error;
  34. }
  35. int test_isNormalized()
  36. {
  37. int Error(0);
  38. bool TestA = glm::isNormalized(glm::vec4(1, 0, 0, 0), 0.00001f);
  39. Error += TestA ? 0 : 1;
  40. return Error;
  41. }
  42. int test_isNull()
  43. {
  44. int Error(0);
  45. bool TestA = glm::isNull(glm::vec4(0), 0.00001f);
  46. Error += TestA ? 0 : 1;
  47. return Error;
  48. }
  49. int test_areOrthonormal()
  50. {
  51. int Error(0);
  52. bool TestA = glm::areOrthonormal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
  53. Error += TestA ? 0 : 1;
  54. return Error;
  55. }
  56. int main()
  57. {
  58. int Error(0);
  59. Error += test_areCollinear();
  60. Error += test_areOrthogonal();
  61. Error += test_isNormalized();
  62. Error += test_isNull();
  63. Error += test_areOrthonormal();
  64. return Error;
  65. }