trigonometric.hpp 10 KB

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