gtx_vector_query.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
  5. /// Permission is hereby granted, free of charge, to any person obtaining a copy
  6. /// of this software and associated documentation files (the "Software"), to deal
  7. /// in the Software without restriction, including without limitation the rights
  8. /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. /// copies of the Software, and to permit persons to whom the Software is
  10. /// furnished to do so, subject to the following conditions:
  11. ///
  12. /// The above copyright notice and this permission notice shall be included in
  13. /// all copies or substantial portions of the Software.
  14. ///
  15. /// Restrictions:
  16. /// By making use of the Software for military purposes, you choose to make
  17. /// a Bunny unhappy.
  18. ///
  19. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. /// THE SOFTWARE.
  26. ///
  27. /// @file test/gtx/gtx_vector_query.cpp
  28. /// @date 2011-11-23 / 2014-11-25
  29. /// @author Christophe Riccio
  30. ///////////////////////////////////////////////////////////////////////////////////
  31. #include <glm/vec2.hpp>
  32. #include <glm/vec3.hpp>
  33. #include <glm/vec4.hpp>
  34. #include <glm/gtx/vector_query.hpp>
  35. int test_areCollinear()
  36. {
  37. int Error(0);
  38. {
  39. bool TestA = glm::areCollinear(glm::vec2(-1), glm::vec2(1), 0.00001f);
  40. Error += TestA ? 0 : 1;
  41. }
  42. {
  43. bool TestA = glm::areCollinear(glm::vec3(-1), glm::vec3(1), 0.00001f);
  44. Error += TestA ? 0 : 1;
  45. }
  46. {
  47. bool TestA = glm::areCollinear(glm::vec4(-1), glm::vec4(1), 0.00001f);
  48. Error += TestA ? 0 : 1;
  49. }
  50. return Error;
  51. }
  52. int test_areOrthogonal()
  53. {
  54. int Error(0);
  55. bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
  56. Error += TestA ? 0 : 1;
  57. return Error;
  58. }
  59. int test_isNormalized()
  60. {
  61. int Error(0);
  62. bool TestA = glm::isNormalized(glm::vec4(1, 0, 0, 0), 0.00001f);
  63. Error += TestA ? 0 : 1;
  64. return Error;
  65. }
  66. int test_isNull()
  67. {
  68. int Error(0);
  69. bool TestA = glm::isNull(glm::vec4(0), 0.00001f);
  70. Error += TestA ? 0 : 1;
  71. return Error;
  72. }
  73. int test_areOrthonormal()
  74. {
  75. int Error(0);
  76. bool TestA = glm::areOrthonormal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
  77. Error += TestA ? 0 : 1;
  78. return Error;
  79. }
  80. int main()
  81. {
  82. int Error(0);
  83. Error += test_areCollinear();
  84. Error += test_areOrthogonal();
  85. Error += test_isNormalized();
  86. Error += test_isNull();
  87. Error += test_areOrthonormal();
  88. return Error;
  89. }