parent
1cf91a1009
commit
2593c9c8b3
12 changed files with 847 additions and 306 deletions
@ -0,0 +1,135 @@ |
||||
/// @ref ext_scalar_reciprocal
|
||||
/// @file glm/ext/scalar_reciprocal.hpp
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup ext_scalar_reciprocal GLM_EXT_scalar_reciprocal
|
||||
/// @ingroup ext
|
||||
///
|
||||
/// Include <glm/ext/scalar_reciprocal.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Define secant, cosecant and cotangent functions.
|
||||
|
||||
#pragma once |
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp" |
||||
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) |
||||
# pragma message("GLM: GLM_EXT_scalar_reciprocal extension included") |
||||
#endif |
||||
|
||||
namespace glm |
||||
{ |
||||
/// @addtogroup ext_scalar_reciprocal
|
||||
/// @{
|
||||
|
||||
/// Secant function.
|
||||
/// hypotenuse / adjacent or 1 / cos(x)
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType sec(genType angle); |
||||
|
||||
/// Cosecant function.
|
||||
/// hypotenuse / opposite or 1 / sin(x)
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType csc(genType angle); |
||||
|
||||
/// Cotangent function.
|
||||
/// adjacent / opposite or 1 / tan(x)
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType cot(genType angle); |
||||
|
||||
/// Inverse secant function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType asec(genType x); |
||||
|
||||
/// Inverse cosecant function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType acsc(genType x); |
||||
|
||||
/// Inverse cotangent function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType acot(genType x); |
||||
|
||||
/// Secant hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType sech(genType angle); |
||||
|
||||
/// Cosecant hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType csch(genType angle); |
||||
|
||||
/// Cotangent hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType coth(genType angle); |
||||
|
||||
/// Inverse secant hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType asech(genType x); |
||||
|
||||
/// Inverse cosecant hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType acsch(genType x); |
||||
|
||||
/// Inverse cotangent hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_scalar_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType acoth(genType x); |
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "scalar_reciprocal.inl" |
@ -0,0 +1,107 @@ |
||||
/// @ref ext_scalar_reciprocal |
||||
|
||||
#include "../trigonometric.hpp" |
||||
#include <limits> |
||||
|
||||
namespace glm |
||||
{ |
||||
// sec |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType sec(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sec' only accept floating-point values"); |
||||
return genType(1) / glm::cos(angle); |
||||
} |
||||
|
||||
// csc |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType csc(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csc' only accept floating-point values"); |
||||
return genType(1) / glm::sin(angle); |
||||
} |
||||
|
||||
// cot |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType cot(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'cot' only accept floating-point values"); |
||||
|
||||
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0); |
||||
return glm::tan(pi_over_2 - angle); |
||||
} |
||||
|
||||
// asec |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType asec(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asec' only accept floating-point values"); |
||||
return acos(genType(1) / x); |
||||
} |
||||
|
||||
// acsc |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType acsc(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsc' only accept floating-point values"); |
||||
return asin(genType(1) / x); |
||||
} |
||||
|
||||
// acot |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType acot(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values"); |
||||
|
||||
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0); |
||||
return pi_over_2 - atan(x); |
||||
} |
||||
|
||||
// sech |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType sech(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sech' only accept floating-point values"); |
||||
return genType(1) / glm::cosh(angle); |
||||
} |
||||
|
||||
// csch |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType csch(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csch' only accept floating-point values"); |
||||
return genType(1) / glm::sinh(angle); |
||||
} |
||||
|
||||
// coth |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType coth(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'coth' only accept floating-point values"); |
||||
return glm::cosh(angle) / glm::sinh(angle); |
||||
} |
||||
|
||||
// asech |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType asech(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asech' only accept floating-point values"); |
||||
return acosh(genType(1) / x); |
||||
} |
||||
|
||||
// acsch |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType acsch(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values"); |
||||
return asinh(genType(1) / x); |
||||
} |
||||
|
||||
// acoth |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType acoth(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acoth' only accept floating-point values"); |
||||
return atanh(genType(1) / x); |
||||
} |
||||
}//namespace glm |
@ -0,0 +1,135 @@ |
||||
/// @ref ext_vector_reciprocal
|
||||
/// @file glm/ext/vector_reciprocal.hpp
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_reciprocal GLM_EXT_vector_reciprocal
|
||||
/// @ingroup ext
|
||||
///
|
||||
/// Include <glm/ext/vector_reciprocal.hpp> to use the features of this extension.
|
||||
///
|
||||
/// Define secant, cosecant and cotangent functions.
|
||||
|
||||
#pragma once |
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp" |
||||
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) |
||||
# pragma message("GLM: GLM_EXT_vector_reciprocal extension included") |
||||
#endif |
||||
|
||||
namespace glm |
||||
{ |
||||
/// @addtogroup ext_vector_reciprocal
|
||||
/// @{
|
||||
|
||||
/// Secant function.
|
||||
/// hypotenuse / adjacent or 1 / cos(x)
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType sec(genType angle); |
||||
|
||||
/// Cosecant function.
|
||||
/// hypotenuse / opposite or 1 / sin(x)
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType csc(genType angle); |
||||
|
||||
/// Cotangent function.
|
||||
/// adjacent / opposite or 1 / tan(x)
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType cot(genType angle); |
||||
|
||||
/// Inverse secant function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType asec(genType x); |
||||
|
||||
/// Inverse cosecant function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType acsc(genType x); |
||||
|
||||
/// Inverse cotangent function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType acot(genType x); |
||||
|
||||
/// Secant hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType sech(genType angle); |
||||
|
||||
/// Cosecant hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType csch(genType angle); |
||||
|
||||
/// Cotangent hyperbolic function.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType coth(genType angle); |
||||
|
||||
/// Inverse secant hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType asech(genType x); |
||||
|
||||
/// Inverse cosecant hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType acsch(genType x); |
||||
|
||||
/// Inverse cotangent hyperbolic function.
|
||||
///
|
||||
/// @return Return an angle expressed in radians.
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
///
|
||||
/// @see ext_vector_reciprocal
|
||||
template<typename genType> |
||||
GLM_FUNC_DECL genType acoth(genType x); |
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "vector_reciprocal.inl" |
@ -0,0 +1,105 @@ |
||||
/// @ref ext_vector_reciprocal |
||||
|
||||
#include "../trigonometric.hpp" |
||||
#include <limits> |
||||
|
||||
namespace glm |
||||
{ |
||||
// sec |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sec(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sec' only accept floating-point inputs"); |
||||
return static_cast<T>(1) / detail::functor1<vec, L, T, T, Q>::call(cos, x); |
||||
} |
||||
|
||||
// csc |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> csc(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csc' only accept floating-point inputs"); |
||||
return static_cast<T>(1) / detail::functor1<vec, L, T, T, Q>::call(sin, x); |
||||
} |
||||
|
||||
// cot |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> cot(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cot' only accept floating-point inputs"); |
||||
T const pi_over_2 = static_cast<T>(3.1415926535897932384626433832795 / 2.0); |
||||
return detail::functor1<vec, L, T, T, Q>::call(tan, pi_over_2 - x); |
||||
} |
||||
|
||||
// asec |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> asec(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asec' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(acos, static_cast<T>(1) / x); |
||||
} |
||||
|
||||
// acsc |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acsc(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsc' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(asin, static_cast<T>(1) / x); |
||||
} |
||||
|
||||
// acot |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acot(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acot' only accept floating-point inputs"); |
||||
T const pi_over_2 = static_cast<T>(3.1415926535897932384626433832795 / 2.0); |
||||
return pi_over_2 - detail::functor1<vec, L, T, T, Q>::call(atan, x); |
||||
} |
||||
|
||||
// sech |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sech(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sech' only accept floating-point inputs"); |
||||
return static_cast<T>(1) / detail::functor1<vec, L, T, T, Q>::call(cosh, x); |
||||
} |
||||
|
||||
// csch |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> csch(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csch' only accept floating-point inputs"); |
||||
return static_cast<T>(1) / detail::functor1<vec, L, T, T, Q>::call(sinh, x); |
||||
} |
||||
|
||||
// coth |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> coth(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'coth' only accept floating-point inputs"); |
||||
return glm::cosh(x) / glm::sinh(x); |
||||
} |
||||
|
||||
// asech |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> asech(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asech' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(acosh, static_cast<T>(1) / x); |
||||
} |
||||
|
||||
// acsch |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acsch(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsch' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(asinh, static_cast<T>(1) / x); |
||||
} |
||||
|
||||
// acoth |
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acoth(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acoth' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(atanh, static_cast<T>(1) / x); |
||||
} |
||||
}//namespace glm |
@ -1,191 +0,0 @@ |
||||
/// @ref gtc_reciprocal |
||||
|
||||
#include "../trigonometric.hpp" |
||||
#include <limits> |
||||
|
||||
namespace glm |
||||
{ |
||||
// sec |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType sec(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sec' only accept floating-point values"); |
||||
return genType(1) / glm::cos(angle); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sec(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sec' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(sec, x); |
||||
} |
||||
|
||||
// csc |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType csc(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csc' only accept floating-point values"); |
||||
return genType(1) / glm::sin(angle); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> csc(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csc' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(csc, x); |
||||
} |
||||
|
||||
// cot |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType cot(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'cot' only accept floating-point values"); |
||||
|
||||
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0); |
||||
return glm::tan(pi_over_2 - angle); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> cot(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cot' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(cot, x); |
||||
} |
||||
|
||||
// asec |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType asec(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asec' only accept floating-point values"); |
||||
return acos(genType(1) / x); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> asec(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asec' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(asec, x); |
||||
} |
||||
|
||||
// acsc |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType acsc(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsc' only accept floating-point values"); |
||||
return asin(genType(1) / x); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acsc(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsc' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(acsc, x); |
||||
} |
||||
|
||||
// acot |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType acot(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values"); |
||||
|
||||
genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0); |
||||
return pi_over_2 - atan(x); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acot(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acot' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(acot, x); |
||||
} |
||||
|
||||
// sech |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType sech(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sech' only accept floating-point values"); |
||||
return genType(1) / glm::cosh(angle); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> sech(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sech' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(sech, x); |
||||
} |
||||
|
||||
// csch |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType csch(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csch' only accept floating-point values"); |
||||
return genType(1) / glm::sinh(angle); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> csch(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'csch' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(csch, x); |
||||
} |
||||
|
||||
// coth |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType coth(genType angle) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'coth' only accept floating-point values"); |
||||
return glm::cosh(angle) / glm::sinh(angle); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> coth(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'coth' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(coth, x); |
||||
} |
||||
|
||||
// asech |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType asech(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asech' only accept floating-point values"); |
||||
return acosh(genType(1) / x); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> asech(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'asech' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(asech, x); |
||||
} |
||||
|
||||
// acsch |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType acsch(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values"); |
||||
return asinh(genType(1) / x); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acsch(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acsch' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(acsch, x); |
||||
} |
||||
|
||||
// acoth |
||||
template<typename genType> |
||||
GLM_FUNC_QUALIFIER genType acoth(genType x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acoth' only accept floating-point values"); |
||||
return atanh(genType(1) / x); |
||||
} |
||||
|
||||
template<length_t L, typename T, qualifier Q> |
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> acoth(vec<L, T, Q> const& x) |
||||
{ |
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'acoth' only accept floating-point inputs"); |
||||
return detail::functor1<vec, L, T, T, Q>::call(acoth, x); |
||||
} |
||||
}//namespace glm |
@ -0,0 +1,171 @@ |
||||
#include <glm/ext/scalar_reciprocal.hpp> |
||||
#include <glm/ext/scalar_relational.hpp> |
||||
#include <glm/ext/scalar_constants.hpp> |
||||
|
||||
static int test_sec() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::equal(glm::sec(0.0), 1.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::sec(glm::pi<double>() * 2.0), 1.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::sec(glm::pi<double>() * -2.0), 1.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::sec(glm::pi<double>() * 1.0), -1.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::sec(glm::pi<double>() * -1.0), -1.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_csc() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
double const a = glm::csc(glm::pi<double>() * 0.5); |
||||
Error += glm::equal(a, 1.0, 0.01) ? 0 : 1; |
||||
double const b = glm::csc(glm::pi<double>() * -0.5); |
||||
Error += glm::equal(b, -1.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_cot() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
double const a = glm::cot(glm::pi<double>() * 0.5); |
||||
Error += glm::equal(a, 0.0, 0.01) ? 0 : 1; |
||||
double const b = glm::cot(glm::pi<double>() * -0.5); |
||||
Error += glm::equal(b, 0.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_asec() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::equal(glm::asec(100000.0), glm::pi<double>() * 0.5, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::asec(-100000.0), glm::pi<double>() * 0.5, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_acsc() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::equal(glm::acsc(100000.0), 0.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::acsc(-100000.0), 0.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_acot() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::equal(glm::acot(100000.0), 0.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::acot(-100000.0), glm::pi<double>(), 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::acot(0.0), glm::pi<double>() * 0.5, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_sech() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::equal(glm::sech(100000.0), 0.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::sech(-100000.0), 0.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::sech(0.0), 1.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_csch() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::equal(glm::csch(100000.0), 0.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::csch(-100000.0), 0.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_coth() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
double const a = glm::coth(100.0); |
||||
Error += glm::equal(a, 1.0, 0.01) ? 0 : 1; |
||||
|
||||
double const b = glm::coth(-100.0); |
||||
Error += glm::equal(b, -1.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_asech() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
double const a = glm::asech(1.0); |
||||
Error += glm::equal(a, 0.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_acsch() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::acsch(0.0001) > 10000.0, 0.01 ? 0 : 1; |
||||
Error += glm::acsch(-0.0001) < -10000.0, 0.01 ? 0 : 1; |
||||
|
||||
Error += glm::equal(glm::acsch(100.0), 0.0, 0.01) ? 0 : 1; |
||||
Error += glm::equal(glm::acsch(-100.0), 0.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_acoth() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
double const a = glm::acoth(1.00001); |
||||
Error += a > 6.0 ? 0 : 1; |
||||
|
||||
double const b = glm::acoth(-1.00001); |
||||
Error += b < -6.0 ? 0 : 1; |
||||
|
||||
double const c = glm::acoth(10000.0); |
||||
Error += glm::equal(c, 0.0, 0.01) ? 0 : 1; |
||||
|
||||
double const d = glm::acoth(-10000.0); |
||||
Error += glm::equal(d, 0.0, 0.01) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
|
||||
int main() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += test_sec(); |
||||
Error += test_csc(); |
||||
Error += test_cot(); |
||||
|
||||
Error += test_asec(); |
||||
Error += test_acsc(); |
||||
Error += test_acot(); |
||||
|
||||
Error += test_sech(); |
||||
Error += test_csch(); |
||||
Error += test_coth(); |
||||
|
||||
Error += test_asech(); |
||||
Error += test_acsch(); |
||||
Error += test_acoth(); |
||||
|
||||
return Error; |
||||
} |
@ -0,0 +1,183 @@ |
||||
#include <glm/ext/vector_reciprocal.hpp> |
||||
#include <glm/ext/vector_relational.hpp> |
||||
#include <glm/ext/scalar_constants.hpp> |
||||
#include <glm/ext/vector_double1.hpp> |
||||
|
||||
static int test_sec() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::dvec1 const a = glm::sec(glm::dvec1(0.0)); |
||||
Error += glm::all(glm::equal(a, glm::dvec1(1.0), 0.01)) ? 0 : 1; |
||||
|
||||
glm::dvec1 const b = glm::sec(glm::dvec1(glm::pi<double>() * 2.0)); |
||||
Error += glm::all(glm::equal(b, glm::dvec1(1.0), 0.01)) ? 0 : 1; |
||||
|
||||
glm::dvec1 const c = glm::sec(glm::dvec1(glm::pi<double>() * -2.0)); |
||||
Error += glm::all(glm::equal(c, glm::dvec1(1.0), 0.01)) ? 0 : 1; |
||||
|
||||
glm::dvec1 const d = glm::sec(glm::dvec1(glm::pi<double>() * 1.0)); |
||||
Error += glm::all(glm::equal(d, -glm::dvec1(1.0), 0.01)) ? 0 : 1; |
||||
|
||||
glm::dvec1 const e = glm::sec(glm::dvec1(glm::pi<double>() * -1.0)); |
||||
Error += glm::all(glm::equal(e, -glm::dvec1(1.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_csc() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::dvec1 const a = glm::csc(glm::dvec1(glm::pi<double>() * 0.5)); |
||||
Error += glm::all(glm::equal(a, glm::dvec1(1.0), 0.01)) ? 0 : 1; |
||||
|
||||
glm::dvec1 const b = glm::csc(glm::dvec1(glm::pi<double>() * -0.5)); |
||||
Error += glm::all(glm::equal(b, glm::dvec1(-1.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_cot() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::dvec1 const a = glm::cot(glm::dvec1(glm::pi<double>() * 0.5)); |
||||
Error += glm::all(glm::equal(a, glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
|
||||
glm::dvec1 const b = glm::cot(glm::dvec1(glm::pi<double>() * -0.5)); |
||||
Error += glm::all(glm::equal(b, glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_asec() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::all(glm::equal(glm::asec(glm::dvec1(100000.0)), glm::dvec1(glm::pi<double>() * 0.5), 0.01)) ? 0 : 1; |
||||
Error += glm::all(glm::equal(glm::asec(glm::dvec1(-100000.0)), glm::dvec1(glm::pi<double>() * 0.5), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_acsc() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::all(glm::equal(glm::acsc(glm::dvec1(100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
Error += glm::all(glm::equal(glm::acsc(glm::dvec1(-100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_acot() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::all(glm::equal(glm::acot(glm::dvec1(100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
Error += glm::all(glm::equal(glm::acot(glm::dvec1(-100000.0)), glm::dvec1(glm::pi<double>()), 0.01)) ? 0 : 1; |
||||
Error += glm::all(glm::equal(glm::acot(glm::dvec1(0.0)), glm::dvec1(glm::pi<double>() * 0.5), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_sech() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::all(glm::equal(glm::sech(glm::dvec1(100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
Error += glm::all(glm::equal(glm::sech(glm::dvec1(-100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
Error += glm::all(glm::equal(glm::sech(glm::dvec1(0.0)), glm::dvec1(1.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_csch() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::all(glm::equal(glm::csch(glm::dvec1(100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
Error += glm::all(glm::equal(glm::csch(glm::dvec1(-100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_coth() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::dvec1 const a = glm::coth(glm::dvec1(100.0)); |
||||
Error += glm::all(glm::equal(a, glm::dvec1(1.0), 0.01)) ? 0 : 1; |
||||
|
||||
glm::dvec1 const b = glm::coth(glm::dvec1(-100.0)); |
||||
Error += glm::all(glm::equal(b, glm::dvec1(-1.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_asech() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::dvec1 const a = glm::asech(glm::dvec1(1.0)); |
||||
Error += glm::all(glm::equal(a, glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_acsch() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += glm::acsch(glm::dvec1(0.0001)).x > 10000.0, 0.01 ? 0 : 1; |
||||
Error += glm::acsch(glm::dvec1(-0.0001)).x < -10000.0, 0.01 ? 0 : 1; |
||||
|
||||
Error += glm::all(glm::equal(glm::acsch(glm::dvec1(100.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
Error += glm::all(glm::equal(glm::acsch(glm::dvec1(-100.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_acoth() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::dvec1 const a = glm::acoth(glm::dvec1(1.00001)); |
||||
Error += a.x > 6.0 ? 0 : 1; |
||||
|
||||
glm::dvec1 const b = glm::acoth(glm::dvec1(-1.00001)); |
||||
Error += b.x < -6.0 ? 0 : 1; |
||||
|
||||
glm::dvec1 const c = glm::acoth(glm::dvec1(10000.0)); |
||||
Error += glm::all(glm::equal(c, glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
|
||||
glm::dvec1 const d = glm::acoth(glm::dvec1(-10000.0)); |
||||
Error += glm::all(glm::equal(d, glm::dvec1(0.0), 0.01)) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
|
||||
int main() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += test_sec(); |
||||
Error += test_csc(); |
||||
Error += test_cot(); |
||||
|
||||
Error += test_asec(); |
||||
Error += test_acsc(); |
||||
Error += test_acot(); |
||||
|
||||
Error += test_sech(); |
||||
Error += test_csch(); |
||||
Error += test_coth(); |
||||
|
||||
Error += test_asech(); |
||||
Error += test_acsch(); |
||||
Error += test_acoth(); |
||||
|
||||
return Error; |
||||
} |
Loading…
Reference in New Issue