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.

43 lines
1.1 KiB

5 years ago
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2005-12-21
  5. // Updated : 2005-12-21
  6. // Licence : This source is under MIT License
  7. // File : glm/gtx/orthonormalize.inl
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. namespace glm
  10. {
  11. template <typename T>
  12. GLM_FUNC_QUALIFIER detail::tmat3x3<T> orthonormalize
  13. (
  14. const detail::tmat3x3<T>& m
  15. )
  16. {
  17. detail::tmat3x3<T> r = m;
  18. r[0] = normalize(r[0]);
  19. float d0 = dot(r[0], r[1]);
  20. r[1] -= r[0] * d0;
  21. r[1] = normalize(r[1]);
  22. float d1 = dot(r[1], r[2]);
  23. d0 = dot(r[0], r[2]);
  24. r[2] -= r[0] * d0 + r[1] * d1;
  25. r[2] = normalize(r[2]);
  26. return r;
  27. }
  28. template <typename T>
  29. GLM_FUNC_QUALIFIER detail::tvec3<T> orthonormalize
  30. (
  31. const detail::tvec3<T>& x,
  32. const detail::tvec3<T>& y
  33. )
  34. {
  35. return normalize(x - y * dot(y, x));
  36. }
  37. }//namespace glm