geometric.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /// @ref core
  2. /// @file glm/geometric.hpp
  3. ///
  4. /// @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>
  5. ///
  6. /// @defgroup core_func_geometric Geometric functions
  7. /// @ingroup core
  8. ///
  9. /// These operate on vectors as vectors, not component-wise.
  10. ///
  11. /// Include <glm/geometric.hpp> to use these core features.
  12. #pragma once
  13. #include "detail/type_vec3.hpp"
  14. namespace glm
  15. {
  16. /// @addtogroup core_func_geometric
  17. /// @{
  18. /// Returns the length of x, i.e., sqrt(x * x).
  19. ///
  20. /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
  21. /// @tparam T Floating-point scalar types.
  22. ///
  23. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
  24. /// @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>
  25. template<length_t L, typename T, qualifier Q>
  26. GLM_FUNC_DECL T length(vec<L, T, Q> const& x);
  27. /// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
  28. ///
  29. /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
  30. /// @tparam T Floating-point scalar types.
  31. ///
  32. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
  33. /// @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>
  34. template<length_t L, typename T, qualifier Q>
  35. GLM_FUNC_DECL T distance(vec<L, T, Q> const& p0, vec<L, T, Q> const& p1);
  36. /// Returns the dot product of x and y, i.e., result = x * y.
  37. ///
  38. /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
  39. /// @tparam T Floating-point scalar types.
  40. ///
  41. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
  42. /// @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>
  43. template<length_t L, typename T, qualifier Q>
  44. GLM_FUNC_DECL T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
  45. /// Returns the cross product of x and y.
  46. ///
  47. /// @tparam T Floating-point scalar types.
  48. ///
  49. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a>
  50. /// @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>
  51. template<typename T, qualifier Q>
  52. GLM_FUNC_DECL vec<3, T, Q> cross(vec<3, T, Q> const& x, vec<3, T, Q> const& y);
  53. /// Returns a vector in the same direction as x but with length of 1.
  54. /// According to issue 10 GLSL 1.10 specification, if length(x) == 0 then result is undefined and generate an error.
  55. ///
  56. /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
  57. /// @tparam T Floating-point scalar types.
  58. ///
  59. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a>
  60. /// @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>
  61. template<length_t L, typename T, qualifier Q>
  62. GLM_FUNC_DECL vec<L, T, Q> normalize(vec<L, T, Q> const& x);
  63. /// If dot(Nref, I) < 0.0, return N, otherwise, return -N.
  64. ///
  65. /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
  66. /// @tparam T Floating-point scalar types.
  67. ///
  68. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a>
  69. /// @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>
  70. template<length_t L, typename T, qualifier Q>
  71. GLM_FUNC_DECL vec<L, T, Q> faceforward(
  72. vec<L, T, Q> const& N,
  73. vec<L, T, Q> const& I,
  74. vec<L, T, Q> const& Nref);
  75. /// For the incident vector I and surface orientation N,
  76. /// returns the reflection direction : result = I - 2.0 * dot(N, I) * N.
  77. ///
  78. /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
  79. /// @tparam T Floating-point scalar types.
  80. ///
  81. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a>
  82. /// @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>
  83. template<length_t L, typename T, qualifier Q>
  84. GLM_FUNC_DECL vec<L, T, Q> reflect(
  85. vec<L, T, Q> const& I,
  86. vec<L, T, Q> const& N);
  87. /// For the incident vector I and surface normal N,
  88. /// and the ratio of indices of refraction eta,
  89. /// return the refraction vector.
  90. ///
  91. /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
  92. /// @tparam T Floating-point scalar types.
  93. ///
  94. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a>
  95. /// @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>
  96. template<length_t L, typename T, qualifier Q>
  97. GLM_FUNC_DECL vec<L, T, Q> refract(
  98. vec<L, T, Q> const& I,
  99. vec<L, T, Q> const& N,
  100. T eta);
  101. /// @}
  102. }//namespace glm
  103. #include "detail/func_geometric.inl"