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