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.

138 lines
5.9 KiB

4 years ago
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2013 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. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. /// THE SOFTWARE.
  22. ///
  23. /// @ref core
  24. /// @file glm/core/func_geometric.hpp
  25. /// @date 2008-08-03 / 2011-06-14
  26. /// @author Christophe Riccio
  27. ///
  28. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  29. ///
  30. /// @defgroup core_func_geometric Geometric functions
  31. /// @ingroup core
  32. ///
  33. /// These operate on vectors as vectors, not component-wise.
  34. ///////////////////////////////////////////////////////////////////////////////////
  35. #ifndef glm_core_func_geometric
  36. #define glm_core_func_geometric GLM_VERSION
  37. namespace glm
  38. {
  39. /// @addtogroup core_func_geometric
  40. /// @{
  41. /// Returns the length of x, i.e., sqrt(x * x).
  42. ///
  43. /// @tparam genType Floating-point vector types.
  44. ///
  45. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
  46. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  47. template <typename genType>
  48. GLM_FUNC_DECL typename genType::value_type length(
  49. genType const & x);
  50. /// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
  51. ///
  52. /// @tparam genType Floating-point vector types.
  53. ///
  54. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
  55. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  56. template <typename genType>
  57. GLM_FUNC_DECL typename genType::value_type distance(
  58. genType const & p0,
  59. genType const & p1);
  60. /// Returns the dot product of x and y, i.e., result = x * y.
  61. ///
  62. /// @tparam genType Floating-point vector types.
  63. ///
  64. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
  65. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  66. template <typename genType>
  67. GLM_FUNC_DECL typename genType::value_type dot(
  68. genType const & x,
  69. genType const & y);
  70. /// Returns the cross product of x and y.
  71. ///
  72. /// @tparam valType Floating-point scalar types.
  73. ///
  74. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a>
  75. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  76. template <typename valType>
  77. GLM_FUNC_DECL detail::tvec3<valType> cross(
  78. detail::tvec3<valType> const & x,
  79. detail::tvec3<valType> const & y);
  80. /// Returns a vector in the same direction as x but with length of 1.
  81. ///
  82. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a>
  83. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  84. template <typename genType>
  85. GLM_FUNC_DECL genType normalize(
  86. genType const & x);
  87. /// If dot(Nref, I) < 0.0, return N, otherwise, return -N.
  88. ///
  89. /// @tparam genType Floating-point vector types.
  90. ///
  91. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a>
  92. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  93. template <typename genType>
  94. GLM_FUNC_DECL genType faceforward(
  95. genType const & N,
  96. genType const & I,
  97. genType const & Nref);
  98. /// For the incident vector I and surface orientation N,
  99. /// returns the reflection direction : result = I - 2.0 * dot(N, I) * N.
  100. ///
  101. /// @tparam genType Floating-point vector types.
  102. ///
  103. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a>
  104. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  105. template <typename genType>
  106. GLM_FUNC_DECL genType reflect(
  107. genType const & I,
  108. genType const & N);
  109. /// For the incident vector I and surface normal N,
  110. /// and the ratio of indices of refraction eta,
  111. /// return the refraction vector.
  112. ///
  113. /// @tparam genType Floating-point vector types.
  114. ///
  115. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a>
  116. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
  117. template <typename genType>
  118. GLM_FUNC_DECL genType refract(
  119. genType const & I,
  120. genType const & N,
  121. typename genType::value_type const & eta);
  122. /// @}
  123. }//namespace glm
  124. #include "func_geometric.inl"
  125. #endif//glm_core_func_geometric