func_trigonometric.hpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /// @ref core
  2. /// @file glm/detail/func_trigonometric.hpp
  3. ///
  4. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  5. ///
  6. /// @defgroup core_func_trigonometric Angle and Trigonometry Functions
  7. /// @ingroup core
  8. ///
  9. /// Function parameters specified as angle are assumed to be in units of radians.
  10. /// In no case will any of these functions result in a divide by zero error. If
  11. /// the divisor of a ratio is 0, then results will be undefined.
  12. ///
  13. /// These all operate component-wise. The description is per component.
  14. #pragma once
  15. #include "setup.hpp"
  16. #include "qualifier.hpp"
  17. namespace glm
  18. {
  19. /// @addtogroup core_func_trigonometric
  20. /// @{
  21. /// Converts degrees to radians and returns the result.
  22. ///
  23. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  24. /// @tparam T Floating-point scalar types
  25. /// @tparam P Enumeration value qualifier
  26. ///
  27. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/radians.xml">GLSL radians man page</a>
  28. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  29. template<length_t L, typename T, qualifier Q>
  30. GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> radians(vec<L, T, Q> const& degrees);
  31. /// Converts radians to degrees and returns the result.
  32. ///
  33. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  34. /// @tparam T Floating-point scalar types
  35. /// @tparam P Enumeration value qualifier
  36. ///
  37. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/degrees.xml">GLSL degrees man page</a>
  38. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  39. template<length_t L, typename T, qualifier Q>
  40. GLM_FUNC_DECL GLM_CONSTEXPR vec<L, T, Q> degrees(vec<L, T, Q> const& radians);
  41. /// The standard trigonometric sine function.
  42. /// The values returned by this function will range from [-1, 1].
  43. ///
  44. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  45. /// @tparam T Floating-point scalar types
  46. /// @tparam P Enumeration value qualifier
  47. ///
  48. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sin.xml">GLSL sin man page</a>
  49. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  50. template<length_t L, typename T, qualifier Q>
  51. GLM_FUNC_DECL vec<L, T, Q> sin(vec<L, T, Q> const& angle);
  52. /// The standard trigonometric cosine function.
  53. /// The values returned by this function will range from [-1, 1].
  54. ///
  55. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  56. /// @tparam T Floating-point scalar types
  57. /// @tparam P Enumeration value qualifier
  58. ///
  59. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cos.xml">GLSL cos 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.1 Angle and Trigonometry Functions</a>
  61. template<length_t L, typename T, qualifier Q>
  62. GLM_FUNC_DECL vec<L, T, Q> cos(vec<L, T, Q> const& angle);
  63. /// The standard trigonometric tangent function.
  64. ///
  65. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  66. /// @tparam T Floating-point scalar types
  67. /// @tparam P Enumeration value qualifier
  68. ///
  69. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tan.xml">GLSL tan man page</a>
  70. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  71. template<length_t L, typename T, qualifier Q>
  72. GLM_FUNC_DECL vec<L, T, Q> tan(vec<L, T, Q> const& angle);
  73. /// Arc sine. Returns an angle whose sine is x.
  74. /// The range of values returned by this function is [-PI/2, PI/2].
  75. /// Results are undefined if |x| > 1.
  76. ///
  77. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  78. /// @tparam T Floating-point scalar types
  79. /// @tparam P Enumeration value qualifier
  80. ///
  81. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asin.xml">GLSL asin 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.1 Angle and Trigonometry Functions</a>
  83. template<length_t L, typename T, qualifier Q>
  84. GLM_FUNC_DECL vec<L, T, Q> asin(vec<L, T, Q> const& x);
  85. /// Arc cosine. Returns an angle whose sine is x.
  86. /// The range of values returned by this function is [0, PI].
  87. /// Results are undefined if |x| > 1.
  88. ///
  89. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  90. /// @tparam T Floating-point scalar types
  91. /// @tparam P Enumeration value qualifier
  92. ///
  93. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acos.xml">GLSL acos man page</a>
  94. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  95. template<length_t L, typename T, qualifier Q>
  96. GLM_FUNC_DECL vec<L, T, Q> acos(vec<L, T, Q> const& x);
  97. /// Arc tangent. Returns an angle whose tangent is y/x.
  98. /// The signs of x and y are used to determine what
  99. /// quadrant the angle is in. The range of values returned
  100. /// by this function is [-PI, PI]. Results are undefined
  101. /// if x and y are both 0.
  102. ///
  103. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  104. /// @tparam T Floating-point scalar types
  105. /// @tparam P Enumeration value qualifier
  106. ///
  107. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
  108. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  109. template<length_t L, typename T, qualifier Q>
  110. GLM_FUNC_DECL vec<L, T, Q> atan(vec<L, T, Q> const& y, vec<L, T, Q> const& x);
  111. /// Arc tangent. Returns an angle whose tangent is y_over_x.
  112. /// The range of values returned by this function is [-PI/2, PI/2].
  113. ///
  114. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  115. /// @tparam T Floating-point scalar types
  116. /// @tparam P Enumeration value qualifier
  117. ///
  118. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
  119. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  120. template<length_t L, typename T, qualifier Q>
  121. GLM_FUNC_DECL vec<L, T, Q> atan(vec<L, T, Q> const& y_over_x);
  122. /// Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2
  123. ///
  124. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  125. /// @tparam T Floating-point scalar types
  126. /// @tparam P Enumeration value qualifier
  127. ///
  128. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sinh.xml">GLSL sinh man page</a>
  129. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  130. template<length_t L, typename T, qualifier Q>
  131. GLM_FUNC_DECL vec<L, T, Q> sinh(vec<L, T, Q> const& angle);
  132. /// Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2
  133. ///
  134. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  135. /// @tparam T Floating-point scalar types
  136. /// @tparam P Enumeration value qualifier
  137. ///
  138. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cosh.xml">GLSL cosh man page</a>
  139. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  140. template<length_t L, typename T, qualifier Q>
  141. GLM_FUNC_DECL vec<L, T, Q> cosh(vec<L, T, Q> const& angle);
  142. /// Returns the hyperbolic tangent function, sinh(angle) / cosh(angle)
  143. ///
  144. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  145. /// @tparam T Floating-point scalar types
  146. /// @tparam P Enumeration value qualifier
  147. ///
  148. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tanh.xml">GLSL tanh man page</a>
  149. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  150. template<length_t L, typename T, qualifier Q>
  151. GLM_FUNC_DECL vec<L, T, Q> tanh(vec<L, T, Q> const& angle);
  152. /// Arc hyperbolic sine; returns the inverse of sinh.
  153. ///
  154. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  155. /// @tparam T Floating-point scalar types
  156. /// @tparam P Enumeration value qualifier
  157. ///
  158. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asinh.xml">GLSL asinh man page</a>
  159. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  160. template<length_t L, typename T, qualifier Q>
  161. GLM_FUNC_DECL vec<L, T, Q> asinh(vec<L, T, Q> const& x);
  162. /// Arc hyperbolic cosine; returns the non-negative inverse
  163. /// of cosh. Results are undefined if x < 1.
  164. ///
  165. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  166. /// @tparam T Floating-point scalar types
  167. /// @tparam P Enumeration value qualifier
  168. ///
  169. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acosh.xml">GLSL acosh man page</a>
  170. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  171. template<length_t L, typename T, qualifier Q>
  172. GLM_FUNC_DECL vec<L, T, Q> acosh(vec<L, T, Q> const& x);
  173. /// Arc hyperbolic tangent; returns the inverse of tanh.
  174. /// Results are undefined if abs(x) >= 1.
  175. ///
  176. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  177. /// @tparam T Floating-point scalar types
  178. /// @tparam P Enumeration value qualifier
  179. ///
  180. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atanh.xml">GLSL atanh man page</a>
  181. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
  182. template<length_t L, typename T, qualifier Q>
  183. GLM_FUNC_DECL vec<L, T, Q> atanh(vec<L, T, Q> const& x);
  184. /// @}
  185. }//namespace glm
  186. #include "func_trigonometric.inl"