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