Collection of DPF-based plugins for packaging
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.

193 lines
6.2KB

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