9
3

orthonormalize.inl 604 B

1234567891011121314151617181920212223242526272829
  1. /// @ref gtx_orthonormalize
  2. namespace glm
  3. {
  4. template<typename T, qualifier Q>
  5. GLM_FUNC_QUALIFIER mat<3, 3, T, Q> orthonormalize(mat<3, 3, T, Q> const& m)
  6. {
  7. mat<3, 3, T, Q> r = m;
  8. r[0] = normalize(r[0]);
  9. T d0 = dot(r[0], r[1]);
  10. r[1] -= r[0] * d0;
  11. r[1] = normalize(r[1]);
  12. T d1 = dot(r[1], r[2]);
  13. d0 = dot(r[0], r[2]);
  14. r[2] -= r[0] * d0 + r[1] * d1;
  15. r[2] = normalize(r[2]);
  16. return r;
  17. }
  18. template<typename T, qualifier Q>
  19. GLM_FUNC_QUALIFIER vec<3, T, Q> orthonormalize(vec<3, T, Q> const& x, vec<3, T, Q> const& y)
  20. {
  21. return normalize(x - y * dot(y, x));
  22. }
  23. }//namespace glm