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
2.5 KiB

  1. //////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  3. //////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2007-09-28
  5. // Updated : 2008-10-07
  6. // Licence : This source is under MIT License
  7. // File : glm/gtx/normalize_dot.inl
  8. //////////////////////////////////////////////////////////////////////////////////
  9. namespace glm
  10. {
  11. template <typename genType>
  12. GLM_FUNC_QUALIFIER genType normalizeDot
  13. (
  14. genType const & x,
  15. genType const & y
  16. )
  17. {
  18. return
  19. glm::dot(x, y) *
  20. glm::inversesqrt(glm::dot(x, x) *
  21. glm::dot(y, y));
  22. }
  23. template <typename valType>
  24. GLM_FUNC_QUALIFIER valType normalizeDot
  25. (
  26. detail::tvec2<valType> const & x,
  27. detail::tvec2<valType> const & y
  28. )
  29. {
  30. return
  31. glm::dot(x, y) *
  32. glm::inversesqrt(glm::dot(x, x) *
  33. glm::dot(y, y));
  34. }
  35. template <typename valType>
  36. GLM_FUNC_QUALIFIER valType normalizeDot
  37. (
  38. detail::tvec3<valType> const & x,
  39. detail::tvec3<valType> const & y
  40. )
  41. {
  42. return
  43. glm::dot(x, y) *
  44. glm::inversesqrt(glm::dot(x, x) *
  45. glm::dot(y, y));
  46. }
  47. template <typename valType>
  48. GLM_FUNC_QUALIFIER valType normalizeDot
  49. (
  50. detail::tvec4<valType> const & x,
  51. detail::tvec4<valType> const & y
  52. )
  53. {
  54. return
  55. glm::dot(x, y) *
  56. glm::inversesqrt(glm::dot(x, x) *
  57. glm::dot(y, y));
  58. }
  59. template <typename genType>
  60. GLM_FUNC_QUALIFIER genType fastNormalizeDot
  61. (
  62. genType const & x,
  63. genType const & y
  64. )
  65. {
  66. return
  67. glm::dot(x, y) *
  68. fastInverseSqrt(glm::dot(x, x) *
  69. glm::dot(y, y));
  70. }
  71. template <typename valType>
  72. GLM_FUNC_QUALIFIER valType fastNormalizeDot
  73. (
  74. detail::tvec2<valType> const & x,
  75. detail::tvec2<valType> const & y
  76. )
  77. {
  78. return
  79. glm::dot(x, y) *
  80. fastInverseSqrt(glm::dot(x, x) *
  81. glm::dot(y, y));
  82. }
  83. template <typename valType>
  84. GLM_FUNC_QUALIFIER valType fastNormalizeDot
  85. (
  86. detail::tvec3<valType> const & x,
  87. detail::tvec3<valType> const & y
  88. )
  89. {
  90. return
  91. glm::dot(x, y) *
  92. fastInverseSqrt(glm::dot(x, x) *
  93. glm::dot(y, y));
  94. }
  95. template <typename valType>
  96. GLM_FUNC_QUALIFIER valType fastNormalizeDot
  97. (
  98. detail::tvec4<valType> const & x,
  99. detail::tvec4<valType> const & y
  100. )
  101. {
  102. return
  103. glm::dot(x, y) *
  104. fastInverseSqrt(glm::dot(x, x) *
  105. glm::dot(y, y));
  106. }
  107. }//namespace glm