scalar_reciprocal.inl 3.3 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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'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. static_assert(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'acoth' only accept floating-point values");
  90. return atanh(genType(1) / x);
  91. }
  92. }//namespace glm