func_geometric.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2008-08-03
  5. // Updated : 2010-02-04
  6. // Licence : This source is under MIT License
  7. // File : glm/core/func_geometric.hpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. #ifndef glm_core_func_geometric
  10. #define glm_core_func_geometric
  11. namespace glm
  12. {
  13. namespace test{
  14. void main_core_func_geometric();
  15. }//namespace test
  16. namespace core{
  17. namespace function{
  18. //! Define all geometric functions from Section 8.4 of GLSL 1.30.8 specification. Included in glm namespace.
  19. namespace geometric{
  20. /// \addtogroup core_funcs
  21. ///@{
  22. //! Returns the length of x, i.e., sqrt(x * x).
  23. //!
  24. //! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
  25. //! \li GLSL 1.30.08 specification, section 8.4
  26. template <typename genType>
  27. typename genType::value_type length(
  28. genType const & x);
  29. //! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
  30. //!
  31. //! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
  32. //! \li GLSL 1.30.08 specification, section 8.4
  33. template <typename genType>
  34. typename genType::value_type distance(
  35. genType const & p0,
  36. genType const & p1);
  37. //! Returns the dot product of x and y, i.e., result = x * y.
  38. //!
  39. //! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
  40. //! \li GLSL 1.30.08 specification, section 8.4
  41. template <typename genType>
  42. typename genType::value_type dot(
  43. genType const & x,
  44. genType const & y);
  45. //! Returns the cross product of x and y.
  46. //!
  47. //! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a>
  48. //! \li GLSL 1.30.08 specification, section 8.4
  49. template <typename T>
  50. detail::tvec3<T> cross(
  51. detail::tvec3<T> const & x,
  52. detail::tvec3<T> const & y);
  53. //! Returns a vector in the same direction as x but with length of 1.
  54. //!
  55. //! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a>
  56. //! \li GLSL 1.30.08 specification, section 8.4
  57. template <typename genType>
  58. genType normalize(
  59. genType const & x);
  60. //! If dot(Nref, I) < 0.0, return N, otherwise, return -N.
  61. //!
  62. //! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a>
  63. //! \li GLSL 1.30.08 specification, section 8.4
  64. template <typename genType>
  65. genType faceforward(
  66. genType const & N,
  67. genType const & I,
  68. genType const & Nref);
  69. //! For the incident vector I and surface orientation N,
  70. //! returns the reflection direction : result = I - 2.0 * dot(N, I) * N.
  71. //!
  72. //! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a>
  73. //! \li GLSL 1.30.08 specification, section 8.4
  74. template <typename genType>
  75. genType reflect(
  76. genType const & I,
  77. genType const & N);
  78. //! For the incident vector I and surface normal N,
  79. //! and the ratio of indices of refraction eta,
  80. //! return the refraction vector.
  81. //!
  82. //! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a>
  83. //! \li GLSL 1.30.08 specification, section 8.4
  84. template <typename genType>
  85. genType refract(
  86. genType const & I,
  87. genType const & N,
  88. typename genType::value_type const & eta);
  89. ///@}
  90. }//namespace geometric
  91. }//namespace function
  92. }//namespace core
  93. using namespace core::function::geometric;
  94. }//namespace glm
  95. #include "func_geometric.inl"
  96. #endif//glm_core_func_geometric