Collection of DPF-based plugins for packaging
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.

115 lines
3.2KB

  1. /// @ref gtx_matrix_query
  2. /// @file glm/gtx/matrix_query.inl
  3. namespace glm
  4. {
  5. template<typename T, qualifier Q>
  6. GLM_FUNC_QUALIFIER bool isNull(mat<2, 2, T, Q> const& m, T const& epsilon)
  7. {
  8. bool result = true;
  9. for(length_t i = 0; result && i < m.length() ; ++i)
  10. result = isNull(m[i], epsilon);
  11. return result;
  12. }
  13. template<typename T, qualifier Q>
  14. GLM_FUNC_QUALIFIER bool isNull(mat<3, 3, T, Q> const& m, T const& epsilon)
  15. {
  16. bool result = true;
  17. for(length_t i = 0; result && i < m.length() ; ++i)
  18. result = isNull(m[i], epsilon);
  19. return result;
  20. }
  21. template<typename T, qualifier Q>
  22. GLM_FUNC_QUALIFIER bool isNull(mat<4, 4, T, Q> const& m, T const& epsilon)
  23. {
  24. bool result = true;
  25. for(length_t i = 0; result && i < m.length() ; ++i)
  26. result = isNull(m[i], epsilon);
  27. return result;
  28. }
  29. template<length_t C, length_t R, typename T, qualifier Q>
  30. GLM_FUNC_QUALIFIER bool isIdentity(mat<C, R, T, Q> const& m, T const& epsilon)
  31. {
  32. bool result = true;
  33. for(length_t i = 0; result && i < m[0].length() ; ++i)
  34. {
  35. for(length_t j = 0; result && j < i ; ++j)
  36. result = abs(m[i][j]) <= epsilon;
  37. if(result)
  38. result = abs(m[i][i] - 1) <= epsilon;
  39. for(length_t j = i + 1; result && j < m.length(); ++j)
  40. result = abs(m[i][j]) <= epsilon;
  41. }
  42. return result;
  43. }
  44. template<typename T, qualifier Q>
  45. GLM_FUNC_QUALIFIER bool isNormalized(mat<2, 2, T, Q> const& m, T const& epsilon)
  46. {
  47. bool result(true);
  48. for(length_t i = 0; result && i < m.length(); ++i)
  49. result = isNormalized(m[i], epsilon);
  50. for(length_t i = 0; result && i < m.length(); ++i)
  51. {
  52. typename mat<2, 2, T, Q>::col_type v;
  53. for(length_t j = 0; j < m.length(); ++j)
  54. v[j] = m[j][i];
  55. result = isNormalized(v, epsilon);
  56. }
  57. return result;
  58. }
  59. template<typename T, qualifier Q>
  60. GLM_FUNC_QUALIFIER bool isNormalized(mat<3, 3, T, Q> const& m, T const& epsilon)
  61. {
  62. bool result(true);
  63. for(length_t i = 0; result && i < m.length(); ++i)
  64. result = isNormalized(m[i], epsilon);
  65. for(length_t i = 0; result && i < m.length(); ++i)
  66. {
  67. typename mat<3, 3, T, Q>::col_type v;
  68. for(length_t j = 0; j < m.length(); ++j)
  69. v[j] = m[j][i];
  70. result = isNormalized(v, epsilon);
  71. }
  72. return result;
  73. }
  74. template<typename T, qualifier Q>
  75. GLM_FUNC_QUALIFIER bool isNormalized(mat<4, 4, T, Q> const& m, T const& epsilon)
  76. {
  77. bool result(true);
  78. for(length_t i = 0; result && i < m.length(); ++i)
  79. result = isNormalized(m[i], epsilon);
  80. for(length_t i = 0; result && i < m.length(); ++i)
  81. {
  82. typename mat<4, 4, T, Q>::col_type v;
  83. for(length_t j = 0; j < m.length(); ++j)
  84. v[j] = m[j][i];
  85. result = isNormalized(v, epsilon);
  86. }
  87. return result;
  88. }
  89. template<length_t C, length_t R, typename T, qualifier Q>
  90. GLM_FUNC_QUALIFIER bool isOrthogonal(mat<C, R, T, Q> const& m, T const& epsilon)
  91. {
  92. bool result = true;
  93. for(length_t i(0); result && i < m.length() - 1; ++i)
  94. for(length_t j(i + 1); result && j < m.length(); ++j)
  95. result = areOrthogonal(m[i], m[j], epsilon);
  96. if(result)
  97. {
  98. mat<C, R, T, Q> tmp = transpose(m);
  99. for(length_t i(0); result && i < m.length() - 1 ; ++i)
  100. for(length_t j(i + 1); result && j < m.length(); ++j)
  101. result = areOrthogonal(tmp[i], tmp[j], epsilon);
  102. }
  103. return result;
  104. }
  105. }//namespace glm