scalar_reciprocal.inl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /// @ref ext_scalar_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. // csc
  14. template<typename genType>
  15. GLM_FUNC_QUALIFIER genType csc(genType angle)
  16. {
  17. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csc' only accept floating-point values");
  18. return genType(1) / glm::sin(angle);
  19. }
  20. // cot
  21. template<typename genType>
  22. GLM_FUNC_QUALIFIER genType cot(genType angle)
  23. {
  24. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'cot' only accept floating-point values");
  25. genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
  26. return glm::tan(pi_over_2 - angle);
  27. }
  28. // asec
  29. template<typename genType>
  30. GLM_FUNC_QUALIFIER genType asec(genType x)
  31. {
  32. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asec' only accept floating-point values");
  33. return acos(genType(1) / x);
  34. }
  35. // acsc
  36. template<typename genType>
  37. GLM_FUNC_QUALIFIER genType acsc(genType x)
  38. {
  39. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsc' only accept floating-point values");
  40. return asin(genType(1) / x);
  41. }
  42. // acot
  43. template<typename genType>
  44. GLM_FUNC_QUALIFIER genType acot(genType x)
  45. {
  46. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values");
  47. genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
  48. return pi_over_2 - atan(x);
  49. }
  50. // sech
  51. template<typename genType>
  52. GLM_FUNC_QUALIFIER genType sech(genType angle)
  53. {
  54. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sech' only accept floating-point values");
  55. return genType(1) / glm::cosh(angle);
  56. }
  57. // csch
  58. template<typename genType>
  59. GLM_FUNC_QUALIFIER genType csch(genType angle)
  60. {
  61. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csch' only accept floating-point values");
  62. return genType(1) / glm::sinh(angle);
  63. }
  64. // coth
  65. template<typename genType>
  66. GLM_FUNC_QUALIFIER genType coth(genType angle)
  67. {
  68. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'coth' only accept floating-point values");
  69. return glm::cosh(angle) / glm::sinh(angle);
  70. }
  71. // asech
  72. template<typename genType>
  73. GLM_FUNC_QUALIFIER genType asech(genType x)
  74. {
  75. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asech' only accept floating-point values");
  76. return acosh(genType(1) / x);
  77. }
  78. // acsch
  79. template<typename genType>
  80. GLM_FUNC_QUALIFIER genType acsch(genType x)
  81. {
  82. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values");
  83. return asinh(genType(1) / x);
  84. }
  85. // acoth
  86. template<typename genType>
  87. GLM_FUNC_QUALIFIER genType acoth(genType x)
  88. {
  89. GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acoth' only accept floating-point values");
  90. return atanh(genType(1) / x);
  91. }
  92. }//namespace glm