reciprocal.inl 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /// @ref gtc_reciprocal
  2. #include "../trigonometric.hpp"
  3. #include <limits>
  4. namespace glm
  5. {
  6. // sec
  7. template<typename genType>
  8. GLM_FUNC_QUALIFIER genType sec(genType angle)
  9. {
  10. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sec' only accept floating-point values");
  11. return genType(1) / glm::cos(angle);
  12. }
  13. template<length_t L, typename T, qualifier Q>
  14. GLM_FUNC_QUALIFIER vec<L, T, Q> sec(vec<L, T, Q> const& x)
  15. {
  16. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sec' only accept floating-point inputs");
  17. return detail::functor1<vec, L, T, T, Q>::call(sec, x);
  18. }
  19. // csc
  20. template<typename genType>
  21. GLM_FUNC_QUALIFIER genType csc(genType angle)
  22. {
  23. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csc' only accept floating-point values");
  24. return genType(1) / glm::sin(angle);
  25. }
  26. template<length_t L, typename T, qualifier Q>
  27. GLM_FUNC_QUALIFIER vec<L, T, Q> csc(vec<L, T, Q> const& x)
  28. {
  29. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csc' only accept floating-point inputs");
  30. return detail::functor1<vec, L, T, T, Q>::call(csc, x);
  31. }
  32. // cot
  33. template<typename genType>
  34. GLM_FUNC_QUALIFIER genType cot(genType angle)
  35. {
  36. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'cot' only accept floating-point values");
  37. genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
  38. return glm::tan(pi_over_2 - angle);
  39. }
  40. template<length_t L, typename T, qualifier Q>
  41. GLM_FUNC_QUALIFIER vec<L, T, Q> cot(vec<L, T, Q> const& x)
  42. {
  43. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cot' only accept floating-point inputs");
  44. return detail::functor1<vec, L, T, T, Q>::call(cot, x);
  45. }
  46. // asec
  47. template<typename genType>
  48. GLM_FUNC_QUALIFIER genType asec(genType x)
  49. {
  50. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asec' only accept floating-point values");
  51. return acos(genType(1) / x);
  52. }
  53. template<length_t L, typename T, qualifier Q>
  54. GLM_FUNC_QUALIFIER vec<L, T, Q> asec(vec<L, T, Q> const& x)
  55. {
  56. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asec' only accept floating-point inputs");
  57. return detail::functor1<vec, L, T, T, Q>::call(asec, x);
  58. }
  59. // acsc
  60. template<typename genType>
  61. GLM_FUNC_QUALIFIER genType acsc(genType x)
  62. {
  63. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsc' only accept floating-point values");
  64. return asin(genType(1) / x);
  65. }
  66. template<length_t L, typename T, qualifier Q>
  67. GLM_FUNC_QUALIFIER vec<L, T, Q> acsc(vec<L, T, Q> const& x)
  68. {
  69. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsc' only accept floating-point inputs");
  70. return detail::functor1<vec, L, T, T, Q>::call(acsc, x);
  71. }
  72. // acot
  73. template<typename genType>
  74. GLM_FUNC_QUALIFIER genType acot(genType x)
  75. {
  76. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values");
  77. genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
  78. return pi_over_2 - atan(x);
  79. }
  80. template<length_t L, typename T, qualifier Q>
  81. GLM_FUNC_QUALIFIER vec<L, T, Q> acot(vec<L, T, Q> const& x)
  82. {
  83. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acot' only accept floating-point inputs");
  84. return detail::functor1<vec, L, T, T, Q>::call(acot, x);
  85. }
  86. // sech
  87. template<typename genType>
  88. GLM_FUNC_QUALIFIER genType sech(genType angle)
  89. {
  90. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sech' only accept floating-point values");
  91. return genType(1) / glm::cosh(angle);
  92. }
  93. template<length_t L, typename T, qualifier Q>
  94. GLM_FUNC_QUALIFIER vec<L, T, Q> sech(vec<L, T, Q> const& x)
  95. {
  96. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sech' only accept floating-point inputs");
  97. return detail::functor1<vec, L, T, T, Q>::call(sech, x);
  98. }
  99. // csch
  100. template<typename genType>
  101. GLM_FUNC_QUALIFIER genType csch(genType angle)
  102. {
  103. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csch' only accept floating-point values");
  104. return genType(1) / glm::sinh(angle);
  105. }
  106. template<length_t L, typename T, qualifier Q>
  107. GLM_FUNC_QUALIFIER vec<L, T, Q> csch(vec<L, T, Q> const& x)
  108. {
  109. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csch' only accept floating-point inputs");
  110. return detail::functor1<vec, L, T, T, Q>::call(csch, x);
  111. }
  112. // coth
  113. template<typename genType>
  114. GLM_FUNC_QUALIFIER genType coth(genType angle)
  115. {
  116. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'coth' only accept floating-point values");
  117. return glm::cosh(angle) / glm::sinh(angle);
  118. }
  119. template<length_t L, typename T, qualifier Q>
  120. GLM_FUNC_QUALIFIER vec<L, T, Q> coth(vec<L, T, Q> const& x)
  121. {
  122. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'coth' only accept floating-point inputs");
  123. return detail::functor1<vec, L, T, T, Q>::call(coth, x);
  124. }
  125. // asech
  126. template<typename genType>
  127. GLM_FUNC_QUALIFIER genType asech(genType x)
  128. {
  129. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asech' only accept floating-point values");
  130. return acosh(genType(1) / x);
  131. }
  132. template<length_t L, typename T, qualifier Q>
  133. GLM_FUNC_QUALIFIER vec<L, T, Q> asech(vec<L, T, Q> const& x)
  134. {
  135. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asech' only accept floating-point inputs");
  136. return detail::functor1<vec, L, T, T, Q>::call(asech, x);
  137. }
  138. // acsch
  139. template<typename genType>
  140. GLM_FUNC_QUALIFIER genType acsch(genType x)
  141. {
  142. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values");
  143. return asinh(genType(1) / x);
  144. }
  145. template<length_t L, typename T, qualifier Q>
  146. GLM_FUNC_QUALIFIER vec<L, T, Q> acsch(vec<L, T, Q> const& x)
  147. {
  148. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsch' only accept floating-point inputs");
  149. return detail::functor1<vec, L, T, T, Q>::call(acsch, x);
  150. }
  151. // acoth
  152. template<typename genType>
  153. GLM_FUNC_QUALIFIER genType acoth(genType x)
  154. {
  155. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acoth' only accept floating-point values");
  156. return atanh(genType(1) / x);
  157. }
  158. template<length_t L, typename T, qualifier Q>
  159. GLM_FUNC_QUALIFIER vec<L, T, Q> acoth(vec<L, T, Q> const& x)
  160. {
  161. GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acoth' only accept floating-point inputs");
  162. return detail::functor1<vec, L, T, T, Q>::call(acoth, x);
  163. }
  164. }//namespace glm