Removed macros
This commit is contained in:
@@ -155,54 +155,6 @@ namespace detail
|
|||||||
}//namespace detail
|
}//namespace detail
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|
||||||
#define VECTORIZE1_VEC(func) \
|
|
||||||
template <typename T, precision P> \
|
|
||||||
GLM_FUNC_QUALIFIER tvec1<T, P> func( \
|
|
||||||
tvec1<T, P> const & v) \
|
|
||||||
{ \
|
|
||||||
return tvec1<T, P>( \
|
|
||||||
func(v.x)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VECTORIZE2_VEC(func) \
|
|
||||||
template <typename T, precision P> \
|
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> func( \
|
|
||||||
tvec2<T, P> const & v) \
|
|
||||||
{ \
|
|
||||||
return tvec2<T, P>( \
|
|
||||||
func(v.x), \
|
|
||||||
func(v.y)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VECTORIZE3_VEC(func) \
|
|
||||||
template <typename T, precision P> \
|
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> func( \
|
|
||||||
tvec3<T, P> const & v) \
|
|
||||||
{ \
|
|
||||||
return tvec3<T, P>( \
|
|
||||||
func(v.x), \
|
|
||||||
func(v.y), \
|
|
||||||
func(v.z)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VECTORIZE4_VEC(func) \
|
|
||||||
template <typename T, precision P> \
|
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> func( \
|
|
||||||
tvec4<T, P> const & v) \
|
|
||||||
{ \
|
|
||||||
return tvec4<T, P>( \
|
|
||||||
func(v.x), \
|
|
||||||
func(v.y), \
|
|
||||||
func(v.z), \
|
|
||||||
func(v.w)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VECTORIZE_VEC(func) \
|
|
||||||
VECTORIZE1_VEC(func) \
|
|
||||||
VECTORIZE2_VEC(func) \
|
|
||||||
VECTORIZE3_VEC(func) \
|
|
||||||
VECTORIZE4_VEC(func)
|
|
||||||
|
|
||||||
#define VECTORIZE1_VEC_SCA(func) \
|
#define VECTORIZE1_VEC_SCA(func) \
|
||||||
template <typename T, precision P> \
|
template <typename T, precision P> \
|
||||||
GLM_FUNC_QUALIFIER tvec1<T, P> func \
|
GLM_FUNC_QUALIFIER tvec1<T, P> func \
|
||||||
@@ -263,66 +215,6 @@ namespace detail
|
|||||||
VECTORIZE3_VEC_SCA(func) \
|
VECTORIZE3_VEC_SCA(func) \
|
||||||
VECTORIZE4_VEC_SCA(func)
|
VECTORIZE4_VEC_SCA(func)
|
||||||
|
|
||||||
#define VECTORIZE1_VEC_VEC(func) \
|
|
||||||
template <typename T, precision P> \
|
|
||||||
GLM_FUNC_QUALIFIER tvec1<T, P> func \
|
|
||||||
( \
|
|
||||||
tvec1<T, P> const & x, \
|
|
||||||
tvec1<T, P> const & y \
|
|
||||||
) \
|
|
||||||
{ \
|
|
||||||
return tvec1<T, P>( \
|
|
||||||
func(x.x, y.x)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VECTORIZE2_VEC_VEC(func) \
|
|
||||||
template <typename T, precision P> \
|
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> func \
|
|
||||||
( \
|
|
||||||
tvec2<T, P> const & x, \
|
|
||||||
tvec2<T, P> const & y \
|
|
||||||
) \
|
|
||||||
{ \
|
|
||||||
return tvec2<T, P>( \
|
|
||||||
func(x.x, y.x), \
|
|
||||||
func(x.y, y.y)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VECTORIZE3_VEC_VEC(func) \
|
|
||||||
template <typename T, precision P> \
|
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> func \
|
|
||||||
( \
|
|
||||||
tvec3<T, P> const & x, \
|
|
||||||
tvec3<T, P> const & y \
|
|
||||||
) \
|
|
||||||
{ \
|
|
||||||
return tvec3<T, P>( \
|
|
||||||
func(x.x, y.x), \
|
|
||||||
func(x.y, y.y), \
|
|
||||||
func(x.z, y.z)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VECTORIZE4_VEC_VEC(func) \
|
|
||||||
template <typename T, precision P> \
|
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> func \
|
|
||||||
( \
|
|
||||||
tvec4<T, P> const & x, \
|
|
||||||
tvec4<T, P> const & y \
|
|
||||||
) \
|
|
||||||
{ \
|
|
||||||
return tvec4<T, P>( \
|
|
||||||
func(x.x, y.x), \
|
|
||||||
func(x.y, y.y), \
|
|
||||||
func(x.z, y.z), \
|
|
||||||
func(x.w, y.w)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VECTORIZE_VEC_VEC(func) \
|
|
||||||
VECTORIZE1_VEC_VEC(func) \
|
|
||||||
VECTORIZE2_VEC_VEC(func) \
|
|
||||||
VECTORIZE3_VEC_VEC(func) \
|
|
||||||
VECTORIZE4_VEC_VEC(func)
|
|
||||||
|
|
||||||
namespace glm{
|
namespace glm{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ namespace glm
|
|||||||
/// @see gtc_random
|
/// @see gtc_random
|
||||||
template <typename genTYpe>
|
template <typename genTYpe>
|
||||||
GLM_FUNC_DECL genTYpe linearRand(
|
GLM_FUNC_DECL genTYpe linearRand(
|
||||||
genTYpe const & Min,
|
genTYpe Min,
|
||||||
genTYpe const & Max);
|
genTYpe Max);
|
||||||
|
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_DECL vecType<T, P> linearRand(
|
GLM_FUNC_DECL vecType<T, P> linearRand(
|
||||||
@@ -75,8 +75,8 @@ namespace glm
|
|||||||
/// @see gtc_random
|
/// @see gtc_random
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType gaussRand(
|
GLM_FUNC_DECL genType gaussRand(
|
||||||
genType const & Mean,
|
genType Mean,
|
||||||
genType const & Deviation);
|
genType Deviation);
|
||||||
|
|
||||||
/// Generate a random 2D vector which coordinates are regulary distributed on a circle of a given radius
|
/// Generate a random 2D vector which coordinates are regulary distributed on a circle of a given radius
|
||||||
///
|
///
|
||||||
@@ -84,7 +84,7 @@ namespace glm
|
|||||||
/// @see gtc_random
|
/// @see gtc_random
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL tvec2<T, defaultp> circularRand(
|
GLM_FUNC_DECL tvec2<T, defaultp> circularRand(
|
||||||
T const & Radius);
|
T Radius);
|
||||||
|
|
||||||
/// Generate a random 3D vector which coordinates are regulary distributed on a sphere of a given radius
|
/// Generate a random 3D vector which coordinates are regulary distributed on a sphere of a given radius
|
||||||
///
|
///
|
||||||
@@ -92,7 +92,7 @@ namespace glm
|
|||||||
/// @see gtc_random
|
/// @see gtc_random
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL tvec3<T, defaultp> sphericalRand(
|
GLM_FUNC_DECL tvec3<T, defaultp> sphericalRand(
|
||||||
T const & Radius);
|
T Radius);
|
||||||
|
|
||||||
/// Generate a random 2D vector which coordinates are regulary distributed within the area of a disk of a given radius
|
/// Generate a random 2D vector which coordinates are regulary distributed within the area of a disk of a given radius
|
||||||
///
|
///
|
||||||
@@ -100,7 +100,7 @@ namespace glm
|
|||||||
/// @see gtc_random
|
/// @see gtc_random
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL tvec2<T, defaultp> diskRand(
|
GLM_FUNC_DECL tvec2<T, defaultp> diskRand(
|
||||||
T const & Radius);
|
T Radius);
|
||||||
|
|
||||||
/// Generate a random 3D vector which coordinates are regulary distributed within the volume of a ball of a given radius
|
/// Generate a random 3D vector which coordinates are regulary distributed within the volume of a ball of a given radius
|
||||||
///
|
///
|
||||||
@@ -108,7 +108,7 @@ namespace glm
|
|||||||
/// @see gtc_random
|
/// @see gtc_random
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL tvec3<T, defaultp> ballRand(
|
GLM_FUNC_DECL tvec3<T, defaultp> ballRand(
|
||||||
T const & Radius);
|
T Radius);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|||||||
@@ -280,46 +280,22 @@ namespace detail
|
|||||||
};
|
};
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
|
|
||||||
|
template <typename genType>
|
||||||
|
GLM_FUNC_QUALIFIER genType linearRand(genType Min, genType Max)
|
||||||
|
{
|
||||||
|
return detail::compute_linearRand<genType, highp, tvec1>::call(
|
||||||
|
tvec1<genType, highp>(Min),
|
||||||
|
tvec1<genType, highp>(Max)).x;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> linearRand
|
GLM_FUNC_QUALIFIER vecType<T, P> linearRand(vecType<T, P> const & Min, vecType<T, P> const & Max)
|
||||||
(
|
|
||||||
vecType<T, P> const & Min,
|
|
||||||
vecType<T, P> const & Max
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return detail::compute_linearRand<T, P, vecType>::call(Min, Max);
|
return detail::compute_linearRand<T, P, vecType>::call(Min, Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
|
||||||
GLM_FUNC_QUALIFIER float linearRand<float>
|
|
||||||
(
|
|
||||||
float const & Min,
|
|
||||||
float const & Max
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::compute_linearRand<float, highp, tvec1>::call(
|
|
||||||
tvec1<float, highp>(Min),
|
|
||||||
tvec1<float, highp>(Max)).x;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
GLM_FUNC_QUALIFIER double linearRand<double>
|
|
||||||
(
|
|
||||||
double const & Min,
|
|
||||||
double const & Max
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::compute_linearRand<double, highp, tvec1>::call(
|
|
||||||
tvec1<double, highp>(Min),
|
|
||||||
tvec1<double, highp>(Max)).x;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType gaussRand
|
GLM_FUNC_QUALIFIER genType gaussRand(genType Mean, genType Deviation)
|
||||||
(
|
|
||||||
genType const & Mean,
|
|
||||||
genType const & Deviation
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
genType w, x1, x2;
|
genType w, x1, x2;
|
||||||
|
|
||||||
@@ -334,13 +310,14 @@ namespace detail
|
|||||||
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
|
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC_VEC(gaussRand)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> gaussRand(vecType<T, P> const & Mean, vecType<T, P> const & Deviation)
|
||||||
|
{
|
||||||
|
return detail::functor2<T, T, P, vecType>::call(gaussRand, Mean, Deviation);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, defaultp> diskRand
|
GLM_FUNC_QUALIFIER tvec2<T, defaultp> diskRand(T Radius)
|
||||||
(
|
|
||||||
T const & Radius
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
tvec2<T, defaultp> Result(T(0));
|
tvec2<T, defaultp> Result(T(0));
|
||||||
T LenRadius(T(0));
|
T LenRadius(T(0));
|
||||||
@@ -358,10 +335,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, defaultp> ballRand
|
GLM_FUNC_QUALIFIER tvec3<T, defaultp> ballRand(T Radius)
|
||||||
(
|
|
||||||
T const & Radius
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
tvec3<T, defaultp> Result(T(0));
|
tvec3<T, defaultp> Result(T(0));
|
||||||
T LenRadius(T(0));
|
T LenRadius(T(0));
|
||||||
@@ -379,20 +353,14 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, defaultp> circularRand
|
GLM_FUNC_QUALIFIER tvec2<T, defaultp> circularRand(T Radius)
|
||||||
(
|
|
||||||
T const & Radius
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||||
return tvec2<T, defaultp>(cos(a), sin(a)) * Radius;
|
return tvec2<T, defaultp>(cos(a), sin(a)) * Radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, defaultp> sphericalRand
|
GLM_FUNC_QUALIFIER tvec3<T, defaultp> sphericalRand(T Radius)
|
||||||
(
|
|
||||||
T const & Radius
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
T z = linearRand(T(-1), T(1));
|
T z = linearRand(T(-1), T(1));
|
||||||
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||||
|
|||||||
@@ -53,41 +53,62 @@ namespace glm
|
|||||||
/// Faster than the common pow function but less accurate.
|
/// Faster than the common pow function but less accurate.
|
||||||
/// @see gtx_fast_exponential
|
/// @see gtx_fast_exponential
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType fastPow(
|
GLM_FUNC_DECL genType fastPow(genType x, genType y);
|
||||||
genType const & x,
|
|
||||||
genType const & y);
|
/// Faster than the common pow function but less accurate.
|
||||||
|
/// @see gtx_fast_exponential
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_DECL vecType<T, P> fastPow(vecType<T, P> const & x, vecType<T, P> const & y);
|
||||||
|
|
||||||
/// Faster than the common pow function but less accurate.
|
/// Faster than the common pow function but less accurate.
|
||||||
/// @see gtx_fast_exponential
|
/// @see gtx_fast_exponential
|
||||||
template <typename genTypeT, typename genTypeU>
|
template <typename genTypeT, typename genTypeU>
|
||||||
GLM_FUNC_DECL genTypeT fastPow(
|
GLM_FUNC_DECL genTypeT fastPow(genTypeT x, genTypeU y);
|
||||||
genTypeT const & x,
|
|
||||||
genTypeU const & y);
|
/// Faster than the common pow function but less accurate.
|
||||||
|
/// @see gtx_fast_exponential
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_DECL vecType<T, P> fastPow(vecType<T, P> const & x);
|
||||||
|
|
||||||
/// Faster than the common exp function but less accurate.
|
/// Faster than the common exp function but less accurate.
|
||||||
/// @see gtx_fast_exponential
|
/// @see gtx_fast_exponential
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastExp(const T& x);
|
GLM_FUNC_DECL T fastExp(T x);
|
||||||
|
|
||||||
|
/// Faster than the common exp function but less accurate.
|
||||||
|
/// @see gtx_fast_exponential
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_DECL vecType<T, P> fastExp(vecType<T, P> const & x);
|
||||||
|
|
||||||
/// Faster than the common log function but less accurate.
|
/// Faster than the common log function but less accurate.
|
||||||
/// @see gtx_fast_exponential
|
/// @see gtx_fast_exponential
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastLog(const T& x);
|
GLM_FUNC_DECL T fastLog(T x);
|
||||||
|
|
||||||
|
/// Faster than the common exp2 function but less accurate.
|
||||||
|
/// @see gtx_fast_exponential
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_DECL vecType<T, P> fastLog(vecType<T, P> const & x);
|
||||||
|
|
||||||
/// Faster than the common exp2 function but less accurate.
|
/// Faster than the common exp2 function but less accurate.
|
||||||
/// @see gtx_fast_exponential
|
/// @see gtx_fast_exponential
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastExp2(const T& x);
|
GLM_FUNC_DECL T fastExp2(T x);
|
||||||
|
|
||||||
|
/// Faster than the common exp2 function but less accurate.
|
||||||
|
/// @see gtx_fast_exponential
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_DECL vecType<T, P> fastExp2(vecType<T, P> const & x);
|
||||||
|
|
||||||
/// Faster than the common log2 function but less accurate.
|
/// Faster than the common log2 function but less accurate.
|
||||||
/// @see gtx_fast_exponential
|
/// @see gtx_fast_exponential
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastLog2(const T& x);
|
GLM_FUNC_DECL T fastLog2(T x);
|
||||||
|
|
||||||
/// Faster than the common ln function but less accurate.
|
/// Faster than the common log2 function but less accurate.
|
||||||
/// @see gtx_fast_exponential
|
/// @see gtx_fast_exponential
|
||||||
template <typename T>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_DECL T fastLn(const T& x);
|
GLM_FUNC_DECL vecType<T, P> fastLog2(vecType<T, P> const & x);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|||||||
@@ -11,15 +11,19 @@ namespace glm
|
|||||||
{
|
{
|
||||||
// fastPow:
|
// fastPow:
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastPow(genType const & x, genType const & y)
|
GLM_FUNC_QUALIFIER genType fastPow(genType x, genType y)
|
||||||
{
|
{
|
||||||
return exp(y * log(x));
|
return exp(y * log(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC_VEC(fastPow)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastPow(vecType<T, P> const & x, vecType<T, P> const & y)
|
||||||
|
{
|
||||||
|
return exp(y * log(x));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
|
GLM_FUNC_QUALIFIER T fastPow(T x, int y)
|
||||||
{
|
{
|
||||||
T f = static_cast<T>(1);
|
T f = static_cast<T>(1);
|
||||||
for(int i = 0; i < y; ++i)
|
for(int i = 0; i < y; ++i)
|
||||||
@@ -27,43 +31,19 @@ namespace glm
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> fastPow(
|
GLM_FUNC_QUALIFIER vecType<T, P> fastPow(vecType<T, P> const & x, vecType<int, P> const & y)
|
||||||
const tvec2<T, P>& x,
|
|
||||||
const tvec2<int, P>& y)
|
|
||||||
{
|
{
|
||||||
return tvec2<T, P>(
|
vecType<T, P> Result(uninitialize);
|
||||||
fastPow(x.x, y.x),
|
for(detail::component_count_t i = 0; i < detail::component_count(x); ++i)
|
||||||
fastPow(x.y, y.y));
|
Result[i] = fastPow(x[i], y[i]);
|
||||||
}
|
return Result;
|
||||||
|
|
||||||
template <typename T, precision P>
|
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> fastPow(
|
|
||||||
const tvec3<T, P>& x,
|
|
||||||
const tvec3<int, P>& y)
|
|
||||||
{
|
|
||||||
return tvec3<T, P>(
|
|
||||||
fastPow(x.x, y.x),
|
|
||||||
fastPow(x.y, y.y),
|
|
||||||
fastPow(x.z, y.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, precision P>
|
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> fastPow(
|
|
||||||
const tvec4<T, P>& x,
|
|
||||||
const tvec4<int, P>& y)
|
|
||||||
{
|
|
||||||
return tvec4<T, P>(
|
|
||||||
fastPow(x.x, y.x),
|
|
||||||
fastPow(x.y, y.y),
|
|
||||||
fastPow(x.z, y.z),
|
|
||||||
fastPow(x.w, y.w));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fastExp
|
// fastExp
|
||||||
// Note: This function provides accurate results only for value between -1 and 1, else avoid it.
|
// Note: This function provides accurate results only for value between -1 and 1, else avoid it.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastExp(const T x)
|
GLM_FUNC_QUALIFIER T fastExp(T x)
|
||||||
{
|
{
|
||||||
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
|
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
|
||||||
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
|
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
|
||||||
@@ -107,11 +87,15 @@ namespace glm
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VECTORIZE_VEC(fastExp)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastExp(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastExp, x);
|
||||||
|
}
|
||||||
|
|
||||||
// fastLog
|
// fastLog
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastLog(genType const & x)
|
GLM_FUNC_QUALIFIER genType fastLog(genType x)
|
||||||
{
|
{
|
||||||
return std::log(x);
|
return std::log(x);
|
||||||
}
|
}
|
||||||
@@ -125,24 +109,35 @@ namespace glm
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VECTORIZE_VEC(fastLog)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastLog(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastLog, x);
|
||||||
|
}
|
||||||
|
|
||||||
//fastExp2, ln2 = 0.69314718055994530941723212145818f
|
//fastExp2, ln2 = 0.69314718055994530941723212145818f
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastExp2(genType const & x)
|
GLM_FUNC_QUALIFIER genType fastExp2(genType x)
|
||||||
{
|
{
|
||||||
return fastExp(0.69314718055994530941723212145818f * x);
|
return fastExp(0.69314718055994530941723212145818f * x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastExp2)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastExp2(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastExp2, x);
|
||||||
|
}
|
||||||
|
|
||||||
// fastLog2, ln2 = 0.69314718055994530941723212145818f
|
// fastLog2, ln2 = 0.69314718055994530941723212145818f
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastLog2(genType const & x)
|
GLM_FUNC_QUALIFIER genType fastLog2(genType x)
|
||||||
{
|
{
|
||||||
return fastLog(x) / 0.69314718055994530941723212145818f;
|
return fastLog(x) / 0.69314718055994530941723212145818f;
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastLog2)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastLog2(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastLog2, x);
|
||||||
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ namespace glm
|
|||||||
//! Faster than the common sqrt function but less accurate.
|
//! Faster than the common sqrt function but less accurate.
|
||||||
//! From GLM_GTX_fast_square_root extension.
|
//! From GLM_GTX_fast_square_root extension.
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType fastSqrt(genType const & x);
|
GLM_FUNC_DECL genType fastSqrt(genType x);
|
||||||
|
|
||||||
//! Faster than the common inversesqrt function but less accurate.
|
//! Faster than the common inversesqrt function but less accurate.
|
||||||
//! From GLM_GTX_fast_square_root extension.
|
//! From GLM_GTX_fast_square_root extension.
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType fastInverseSqrt(genType const & x);
|
GLM_FUNC_DECL genType fastInverseSqrt(genType x);
|
||||||
|
|
||||||
//! Faster than the common inversesqrt function but less accurate.
|
//! Faster than the common inversesqrt function but less accurate.
|
||||||
//! From GLM_GTX_fast_square_root extension.
|
//! From GLM_GTX_fast_square_root extension.
|
||||||
@@ -74,7 +74,12 @@ namespace glm
|
|||||||
//! Faster than the common distance function but less accurate.
|
//! Faster than the common distance function but less accurate.
|
||||||
//! From GLM_GTX_fast_square_root extension.
|
//! From GLM_GTX_fast_square_root extension.
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL typename genType::value_type fastDistance(genType const & x, genType const & y);
|
GLM_FUNC_DECL genType fastDistance(genType x, genType y);
|
||||||
|
|
||||||
|
//! Faster than the common distance function but less accurate.
|
||||||
|
//! From GLM_GTX_fast_square_root extension.
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_DECL T fastDistance(vecType<T, P> const & x, vecType<T, P> const & y);
|
||||||
|
|
||||||
//! Faster than the common normalize function but less accurate.
|
//! Faster than the common normalize function but less accurate.
|
||||||
//! From GLM_GTX_fast_square_root extension.
|
//! From GLM_GTX_fast_square_root extension.
|
||||||
|
|||||||
@@ -11,170 +11,77 @@ namespace glm
|
|||||||
{
|
{
|
||||||
// fastSqrt
|
// fastSqrt
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastSqrt
|
GLM_FUNC_QUALIFIER genType fastSqrt(genType x)
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fastSqrt' only accept floating-point input");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fastSqrt' only accept floating-point input");
|
||||||
|
|
||||||
return genType(1) / fastInverseSqrt(x);
|
return genType(1) / fastInverseSqrt(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastSqrt)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastSqrt(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastSqrt, x);
|
||||||
|
}
|
||||||
|
|
||||||
// fastInversesqrt
|
// fastInversesqrt
|
||||||
template <>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER float fastInverseSqrt<float>(float const & x)
|
GLM_FUNC_QUALIFIER genType fastInverseSqrt(genType x)
|
||||||
{
|
{
|
||||||
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
|
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
|
||||||
tvec1<T, P> tmp(detail::compute_inversesqrt<tvec1, float, lowp>::call(tvec1<float, lowp>(x)));
|
tvec1<T, P> tmp(detail::compute_inversesqrt<tvec1, genType, lowp>::call(tvec1<genType, lowp>(x)));
|
||||||
return tmp.x;
|
return tmp.x;
|
||||||
# else
|
# else
|
||||||
return detail::compute_inversesqrt<tvec1, float, lowp>::call(tvec1<float, lowp>(x)).x;
|
return detail::compute_inversesqrt<tvec1, genType, lowp>::call(tvec1<genType, lowp>(x)).x;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER double fastInverseSqrt<double>(double const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> fastInverseSqrt(vecType<T, P> const & x)
|
||||||
{
|
|
||||||
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
|
|
||||||
tvec1<T, P> tmp(detail::compute_inversesqrt<tvec1, double, lowp>::call(tvec1<double, lowp>(x)));
|
|
||||||
return tmp.x;
|
|
||||||
# else
|
|
||||||
return detail::compute_inversesqrt<tvec1, double, lowp>::call(tvec1<double, lowp>(x)).x;
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template <template <class, precision> class vecType, typename T, precision P>
|
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> fastInverseSqrt
|
|
||||||
(
|
|
||||||
vecType<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return detail::compute_inversesqrt<vecType, T, P>::call(x);
|
return detail::compute_inversesqrt<vecType, T, P>::call(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastInverseSqrt)
|
|
||||||
|
|
||||||
// fastLength
|
// fastLength
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastLength
|
GLM_FUNC_QUALIFIER genType fastLength(genType x)
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fastLength' only accept floating-point inputs");
|
||||||
|
|
||||||
return abs(x);
|
return abs(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType, precision P>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER valType fastLength
|
GLM_FUNC_QUALIFIER T fastLength(vecType<T, P> const & x)
|
||||||
(
|
|
||||||
tvec2<valType, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
valType sqr = x.x * x.x + x.y * x.y;
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fastLength' only accept floating-point inputs");
|
||||||
return fastSqrt(sqr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType, precision P>
|
return fastSqrt(dot(x, x));
|
||||||
GLM_FUNC_QUALIFIER valType fastLength
|
|
||||||
(
|
|
||||||
tvec3<valType, P> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z;
|
|
||||||
return fastSqrt(sqr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType, precision P>
|
|
||||||
GLM_FUNC_QUALIFIER valType fastLength
|
|
||||||
(
|
|
||||||
tvec4<valType, P> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w;
|
|
||||||
return fastSqrt(sqr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fastDistance
|
// fastDistance
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastDistance
|
GLM_FUNC_QUALIFIER genType fastDistance(genType x, genType y)
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
genType const & y
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return fastLength(y - x);
|
return fastLength(y - x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType, precision P>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER valType fastDistance
|
GLM_FUNC_QUALIFIER T fastDistance(vecType<T, P> const & x, vecType<T, P> const & y)
|
||||||
(
|
|
||||||
tvec2<valType, P> const & x,
|
|
||||||
tvec2<valType, P> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return fastLength(y - x);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType, precision P>
|
|
||||||
GLM_FUNC_QUALIFIER valType fastDistance
|
|
||||||
(
|
|
||||||
tvec3<valType, P> const & x,
|
|
||||||
tvec3<valType, P> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return fastLength(y - x);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType, precision P>
|
|
||||||
GLM_FUNC_QUALIFIER valType fastDistance
|
|
||||||
(
|
|
||||||
tvec4<valType, P> const & x,
|
|
||||||
tvec4<valType, P> const & y
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return fastLength(y - x);
|
return fastLength(y - x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fastNormalize
|
// fastNormalize
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastNormalize
|
GLM_FUNC_QUALIFIER genType fastNormalize(genType x)
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return x > genType(0) ? genType(1) : -genType(1);
|
return x > genType(0) ? genType(1) : -genType(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType, precision P>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER tvec2<valType, P> fastNormalize
|
GLM_FUNC_QUALIFIER vecType<T, P> fastNormalize(vecType<T, P> const & x)
|
||||||
(
|
|
||||||
tvec2<valType, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
valType sqr = x.x * x.x + x.y * x.y;
|
return x * fastInverseSqrt(dot(x, x));
|
||||||
return x * fastInverseSqrt(sqr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType, precision P>
|
|
||||||
GLM_FUNC_QUALIFIER tvec3<valType, P> fastNormalize
|
|
||||||
(
|
|
||||||
tvec3<valType, P> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z;
|
|
||||||
return x * fastInverseSqrt(sqr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType, precision P>
|
|
||||||
GLM_FUNC_QUALIFIER tvec4<valType, P> fastNormalize
|
|
||||||
(
|
|
||||||
tvec4<valType, P> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w;
|
|
||||||
return x * fastInverseSqrt(sqr);
|
|
||||||
}
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|||||||
@@ -53,43 +53,43 @@ namespace glm
|
|||||||
//! Defined between -2pi and 2pi.
|
//! Defined between -2pi and 2pi.
|
||||||
//! From GLM_GTX_fast_trigonometry extension.
|
//! From GLM_GTX_fast_trigonometry extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastSin(const T& angle);
|
GLM_FUNC_DECL T fastSin(T angle);
|
||||||
|
|
||||||
//! Faster than the common cos function but less accurate.
|
//! Faster than the common cos function but less accurate.
|
||||||
//! Defined between -2pi and 2pi.
|
//! Defined between -2pi and 2pi.
|
||||||
//! From GLM_GTX_fast_trigonometry extension.
|
//! From GLM_GTX_fast_trigonometry extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastCos(const T& angle);
|
GLM_FUNC_DECL T fastCos(T angle);
|
||||||
|
|
||||||
//! Faster than the common tan function but less accurate.
|
//! Faster than the common tan function but less accurate.
|
||||||
//! Defined between -2pi and 2pi.
|
//! Defined between -2pi and 2pi.
|
||||||
//! From GLM_GTX_fast_trigonometry extension.
|
//! From GLM_GTX_fast_trigonometry extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastTan(const T& angle);
|
GLM_FUNC_DECL T fastTan(T angle);
|
||||||
|
|
||||||
//! Faster than the common asin function but less accurate.
|
//! Faster than the common asin function but less accurate.
|
||||||
//! Defined between -2pi and 2pi.
|
//! Defined between -2pi and 2pi.
|
||||||
//! From GLM_GTX_fast_trigonometry extension.
|
//! From GLM_GTX_fast_trigonometry extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastAsin(const T& angle);
|
GLM_FUNC_DECL T fastAsin(T angle);
|
||||||
|
|
||||||
//! Faster than the common acos function but less accurate.
|
//! Faster than the common acos function but less accurate.
|
||||||
//! Defined between -2pi and 2pi.
|
//! Defined between -2pi and 2pi.
|
||||||
//! From GLM_GTX_fast_trigonometry extension.
|
//! From GLM_GTX_fast_trigonometry extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastAcos(const T& angle);
|
GLM_FUNC_DECL T fastAcos(T angle);
|
||||||
|
|
||||||
//! Faster than the common atan function but less accurate.
|
//! Faster than the common atan function but less accurate.
|
||||||
//! Defined between -2pi and 2pi.
|
//! Defined between -2pi and 2pi.
|
||||||
//! From GLM_GTX_fast_trigonometry extension.
|
//! From GLM_GTX_fast_trigonometry extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastAtan(const T& y, const T& x);
|
GLM_FUNC_DECL T fastAtan(T y, T x);
|
||||||
|
|
||||||
//! Faster than the common atan function but less accurate.
|
//! Faster than the common atan function but less accurate.
|
||||||
//! Defined between -2pi and 2pi.
|
//! Defined between -2pi and 2pi.
|
||||||
//! From GLM_GTX_fast_trigonometry extension.
|
//! From GLM_GTX_fast_trigonometry extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_DECL T fastAtan(const T& angle);
|
GLM_FUNC_DECL T fastAtan(T angle);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|||||||
@@ -11,65 +11,92 @@ namespace glm
|
|||||||
{
|
{
|
||||||
// sin
|
// sin
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastSin(T const & x)
|
GLM_FUNC_QUALIFIER T fastSin(T x)
|
||||||
{
|
{
|
||||||
return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040));
|
return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040));
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastSin)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastSin(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastSin, x);
|
||||||
|
}
|
||||||
|
|
||||||
// cos
|
// cos
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastCos(T const & x)
|
GLM_FUNC_QUALIFIER T fastCos(T x)
|
||||||
{
|
{
|
||||||
return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888));
|
return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888));
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastCos)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastCos(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastCos, x);
|
||||||
|
}
|
||||||
|
|
||||||
// tan
|
// tan
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastTan(T const & x)
|
GLM_FUNC_QUALIFIER T fastTan(T x)
|
||||||
{
|
{
|
||||||
return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539));
|
return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539));
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastTan)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastTan(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastTan, x);
|
||||||
|
}
|
||||||
|
|
||||||
// asin
|
// asin
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastAsin(T const & x)
|
GLM_FUNC_QUALIFIER T fastAsin(T x)
|
||||||
{
|
{
|
||||||
return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159));
|
return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159));
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastAsin)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastAsin(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastAsin, x);
|
||||||
|
}
|
||||||
|
|
||||||
// acos
|
// acos
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastAcos(T const & x)
|
GLM_FUNC_QUALIFIER T fastAcos(T x)
|
||||||
{
|
{
|
||||||
return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2)
|
return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastAcos)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastAcos(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastAcos, x);
|
||||||
|
}
|
||||||
|
|
||||||
// atan
|
// atan
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastAtan(T const & y, T const & x)
|
GLM_FUNC_QUALIFIER T fastAtan(T y, T x)
|
||||||
{
|
{
|
||||||
T sgn = sign(y) * sign(x);
|
T sgn = sign(y) * sign(x);
|
||||||
return abs(fastAtan(y / x)) * sgn;
|
return abs(fastAtan(y / x)) * sgn;
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC_VEC(fastAtan)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastAtan(vecType<T, P> const & y, vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor2<T, T, P, vecType>::call(fastAtan, y, x);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastAtan(T const & x)
|
GLM_FUNC_QUALIFIER T fastAtan(T x)
|
||||||
{
|
{
|
||||||
return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909));
|
return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909));
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fastAtan)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fastAtan(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, T, P, vecType>::call(fastAtan, x);
|
||||||
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ namespace glm
|
|||||||
/// @see gtx_multiple
|
/// @see gtx_multiple
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType higherMultiple(
|
GLM_FUNC_DECL genType higherMultiple(
|
||||||
genType const & Source,
|
genType Source,
|
||||||
genType const & Multiple);
|
genType Multiple);
|
||||||
|
|
||||||
/// Lower multiple number of Source.
|
/// Lower multiple number of Source.
|
||||||
///
|
///
|
||||||
@@ -71,8 +71,8 @@ namespace glm
|
|||||||
/// @see gtx_multiple
|
/// @see gtx_multiple
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType lowerMultiple(
|
GLM_FUNC_DECL genType lowerMultiple(
|
||||||
genType const & Source,
|
genType Source,
|
||||||
genType const & Multiple);
|
genType Multiple);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|||||||
@@ -17,13 +17,9 @@ namespace detail
|
|||||||
struct higherMultiple
|
struct higherMultiple
|
||||||
{
|
{
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType operator()
|
GLM_FUNC_QUALIFIER genType operator()(genType Source, genType Multiple)
|
||||||
(
|
|
||||||
genType const & Source,
|
|
||||||
genType const & Multiple
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Source > genType(0))
|
if(Source > genType(0))
|
||||||
{
|
{
|
||||||
genType Tmp = Source - genType(1);
|
genType Tmp = Source - genType(1);
|
||||||
return Tmp + (Multiple - (Tmp % Multiple));
|
return Tmp + (Multiple - (Tmp % Multiple));
|
||||||
@@ -37,11 +33,7 @@ namespace detail
|
|||||||
struct higherMultiple<false>
|
struct higherMultiple<false>
|
||||||
{
|
{
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType operator()
|
GLM_FUNC_QUALIFIER genType operator()(genType Source, genType Multiple)
|
||||||
(
|
|
||||||
genType const & Source,
|
|
||||||
genType const & Multiple
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
genType Tmp = Source - genType(1);
|
genType Tmp = Source - genType(1);
|
||||||
return Tmp + (Multiple - (Tmp % Multiple));
|
return Tmp + (Multiple - (Tmp % Multiple));
|
||||||
@@ -53,24 +45,16 @@ namespace detail
|
|||||||
// higherMultiple
|
// higherMultiple
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType higherMultiple
|
GLM_FUNC_QUALIFIER genType higherMultiple(genType Source, genType Multiple)
|
||||||
(
|
|
||||||
genType const & Source,
|
|
||||||
genType const & Multiple
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
detail::higherMultiple<std::numeric_limits<genType>::is_signed> Compute;
|
detail::higherMultiple<std::numeric_limits<genType>::is_signed> Compute;
|
||||||
return Compute(Source, Multiple);
|
return Compute(Source, Multiple);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER float higherMultiple
|
GLM_FUNC_QUALIFIER float higherMultiple(float Source, float Multiple)
|
||||||
(
|
|
||||||
float const & Source,
|
|
||||||
float const & Multiple
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Source > float(0))
|
if(Source > float(0))
|
||||||
{
|
{
|
||||||
float Tmp = Source - float(1);
|
float Tmp = Source - float(1);
|
||||||
return Tmp + (Multiple - std::fmod(Tmp, Multiple));
|
return Tmp + (Multiple - std::fmod(Tmp, Multiple));
|
||||||
@@ -80,13 +64,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER double higherMultiple
|
GLM_FUNC_QUALIFIER double higherMultiple(double Source, double Multiple)
|
||||||
(
|
|
||||||
double const & Source,
|
|
||||||
double const & Multiple
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Source > double(0))
|
if(Source > double(0))
|
||||||
{
|
{
|
||||||
double Tmp = Source - double(1);
|
double Tmp = Source - double(1);
|
||||||
return Tmp + (Multiple - std::fmod(Tmp, Multiple));
|
return Tmp + (Multiple - std::fmod(Tmp, Multiple));
|
||||||
@@ -95,19 +75,19 @@ namespace detail
|
|||||||
return Source + std::fmod(-Source, Multiple);
|
return Source + std::fmod(-Source, Multiple);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC_VEC(higherMultiple)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> higherMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
|
||||||
|
{
|
||||||
|
return detail::functor2<T, T, P, vecType>::call(higherMultiple, Source, Multiple);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// lowerMultiple
|
// lowerMultiple
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType lowerMultiple
|
GLM_FUNC_QUALIFIER genType lowerMultiple(genType Source, genType Multiple)
|
||||||
(
|
|
||||||
genType const & Source,
|
|
||||||
genType const & Multiple
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Source >= genType(0))
|
if(Source >= genType(0))
|
||||||
return Source - Source % Multiple;
|
return Source - Source % Multiple;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -117,13 +97,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER float lowerMultiple
|
GLM_FUNC_QUALIFIER float lowerMultiple(float Source, float Multiple)
|
||||||
(
|
|
||||||
float const & Source,
|
|
||||||
float const & Multiple
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Source >= float(0))
|
if(Source >= float(0))
|
||||||
return Source - std::fmod(Source, Multiple);
|
return Source - std::fmod(Source, Multiple);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -133,11 +109,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER double lowerMultiple
|
GLM_FUNC_QUALIFIER double lowerMultiple(double Source, double Multiple)
|
||||||
(
|
|
||||||
double const & Source,
|
|
||||||
double const & Multiple
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Source >= double(0))
|
if (Source >= double(0))
|
||||||
return Source - std::fmod(Source, Multiple);
|
return Source - std::fmod(Source, Multiple);
|
||||||
@@ -148,5 +120,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC_VEC(lowerMultiple)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> lowerMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
|
||||||
|
{
|
||||||
|
return detail::functor2<T, T, P, vecType>::call(lowerMultiple, Source, Multiple);
|
||||||
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|||||||
Reference in New Issue
Block a user