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.

199 lines
4.6 KiB

  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 gtc_reciprocal
  24. /// @file glm/gtc/reciprocal.inl
  25. /// @date 2008-10-09 / 2012-04-07
  26. /// @author Christophe Riccio
  27. ///////////////////////////////////////////////////////////////////////////////////
  28. namespace glm
  29. {
  30. // sec
  31. template <typename genType>
  32. GLM_FUNC_QUALIFIER genType sec
  33. (
  34. genType const & angle
  35. )
  36. {
  37. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sec' only accept floating-point values");
  38. return genType(1) / glm::cos(angle);
  39. }
  40. VECTORIZE_VEC(sec)
  41. // csc
  42. template <typename genType>
  43. GLM_FUNC_QUALIFIER genType csc
  44. (
  45. genType const & angle
  46. )
  47. {
  48. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csc' only accept floating-point values");
  49. return genType(1) / glm::sin(angle);
  50. }
  51. VECTORIZE_VEC(csc)
  52. // cot
  53. template <typename genType>
  54. GLM_FUNC_QUALIFIER genType cot
  55. (
  56. genType const & angle
  57. )
  58. {
  59. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cot' only accept floating-point values");
  60. return genType(1) / glm::tan(angle);
  61. }
  62. VECTORIZE_VEC(cot)
  63. // asec
  64. template <typename genType>
  65. GLM_FUNC_QUALIFIER genType asec
  66. (
  67. genType const & x
  68. )
  69. {
  70. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asec' only accept floating-point values");
  71. return acos(genType(1) / x);
  72. }
  73. VECTORIZE_VEC(asec)
  74. // acsc
  75. template <typename genType>
  76. GLM_FUNC_QUALIFIER genType acsc
  77. (
  78. genType const & x
  79. )
  80. {
  81. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsc' only accept floating-point values");
  82. return asin(genType(1) / x);
  83. }
  84. VECTORIZE_VEC(acsc)
  85. // acot
  86. template <typename genType>
  87. GLM_FUNC_QUALIFIER genType acot
  88. (
  89. genType const & x
  90. )
  91. {
  92. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acot' only accept floating-point values");
  93. genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
  94. return pi_over_2 - atan(x);
  95. }
  96. VECTORIZE_VEC(acot)
  97. // sech
  98. template <typename genType>
  99. GLM_FUNC_QUALIFIER genType sech
  100. (
  101. genType const & angle
  102. )
  103. {
  104. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sech' only accept floating-point values");
  105. return genType(1) / glm::cosh(angle);
  106. }
  107. VECTORIZE_VEC(sech)
  108. // csch
  109. template <typename genType>
  110. GLM_FUNC_QUALIFIER genType csch
  111. (
  112. genType const & angle
  113. )
  114. {
  115. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'csch' only accept floating-point values");
  116. return genType(1) / glm::sinh(angle);
  117. }
  118. VECTORIZE_VEC(csch)
  119. // coth
  120. template <typename genType>
  121. GLM_FUNC_QUALIFIER genType coth
  122. (
  123. genType const & angle
  124. )
  125. {
  126. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'coth' only accept floating-point values");
  127. return glm::cosh(angle) / glm::sinh(angle);
  128. }
  129. VECTORIZE_VEC(coth)
  130. // asech
  131. template <typename genType>
  132. GLM_FUNC_QUALIFIER genType asech
  133. (
  134. genType const & x
  135. )
  136. {
  137. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asech' only accept floating-point values");
  138. return acosh(genType(1) / x);
  139. }
  140. VECTORIZE_VEC(asech)
  141. // acsch
  142. template <typename genType>
  143. GLM_FUNC_QUALIFIER genType acsch
  144. (
  145. genType const & x
  146. )
  147. {
  148. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acsch' only accept floating-point values");
  149. return asinh(genType(1) / x);
  150. }
  151. VECTORIZE_VEC(acsch)
  152. // acoth
  153. template <typename genType>
  154. GLM_FUNC_QUALIFIER genType acoth
  155. (
  156. genType const & x
  157. )
  158. {
  159. GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acoth' only accept floating-point values");
  160. return atanh(genType(1) / x);
  161. }
  162. VECTORIZE_VEC(acoth)
  163. }//namespace glm