Renamed precision enum to qualifier

This commit is contained in:
Christophe Riccio
2017-08-15 21:23:47 +02:00
parent a7b72ec5b2
commit a805fb9d68
201 changed files with 5026 additions and 5127 deletions

View File

@@ -173,17 +173,17 @@ namespace fastAtan
namespace taylorCos
{
using glm::precision;
using glm::qualifier;
glm::vec4 const AngleShift(0.0f, glm::half_pi<float>(), glm::pi<float>(), glm::three_over_two_pi<float>());
template<glm::length_t L, typename T, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> taylorSeriesNewCos(vecType<L, T, P> const & x)
template<glm::length_t L, typename T, qualifier P>
GLM_FUNC_QUALIFIER glm::vec<L, T, P> taylorSeriesNewCos(glm::vec<L, T, P> const & x)
{
vecType<L, T, P> const Powed2(x * x);
vecType<L, T, P> const Powed4(Powed2 * Powed2);
vecType<L, T, P> const Powed6(Powed4 * Powed2);
vecType<L, T, P> const Powed8(Powed4 * Powed4);
glm::vec<L, T, P> const Powed2(x * x);
glm::vec<L, T, P> const Powed4(Powed2 * Powed2);
glm::vec<L, T, P> const Powed6(Powed4 * Powed2);
glm::vec<L, T, P> const Powed8(Powed4 * Powed4);
return static_cast<T>(1)
- Powed2 * static_cast<T>(0.5)
@@ -192,12 +192,12 @@ namespace taylorCos
+ Powed8 * static_cast<T>(2.4801587301587301587301587301587e-5);
}
template<glm::length_t L, typename T, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> taylorSeriesNewCos6(vecType<L, T, P> const & x)
template<glm::length_t L, typename T, qualifier P>
GLM_FUNC_QUALIFIER glm::vec<L, T, P> taylorSeriesNewCos6(glm::vec<L, T, P> const & x)
{
vecType<L, T, P> const Powed2(x * x);
vecType<L, T, P> const Powed4(Powed2 * Powed2);
vecType<L, T, P> const Powed6(Powed4 * Powed2);
glm::vec<L, T, P> const Powed2(x * x);
glm::vec<L, T, P> const Powed4(Powed2 * Powed2);
glm::vec<L, T, P> const Powed6(Powed4 * Powed2);
return static_cast<T>(1)
- Powed2 * static_cast<T>(0.5)
@@ -205,8 +205,8 @@ namespace taylorCos
- Powed6 * static_cast<T>(0.00138888888888888888888888888889);
}
template<glm::length_t L, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, float, P> fastAbs(vecType<L, float, P> x)
template<glm::length_t L, qualifier P>
GLM_FUNC_QUALIFIER glm::vec<L, float, P> fastAbs(glm::vec<L, float, P> x)
{
int* Pointer = reinterpret_cast<int*>(&x[0]);
Pointer[0] &= 0x7fffffff;
@@ -216,17 +216,17 @@ namespace taylorCos
return x;
}
template<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> fastCosNew(vecType<L, T, P> const & x)
template<glm::length_t L, typename T, glm::qualifier P>
GLM_FUNC_QUALIFIER glm::vec<L, T, P> fastCosNew(glm::vec<L, T, P> const & x)
{
vecType<L, T, P> const Angle0_PI(fastAbs(fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
glm::vec<L, T, P> const Angle0_PI(fastAbs(fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
return taylorSeriesNewCos6(x);
/*
vecType<L, bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType<L, T, P>(glm::half_pi<T>())));
vec<L, bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vec<L, T, P>(glm::half_pi<T>())));
vecType<L, T, P> const RevertAngle(mix(vecType<L, T, P>(glm::pi<T>()), vecType<L, T, P>(0), FirstQuarterPi));
vecType<L, T, P> const ReturnSign(mix(vecType<L, T, P>(-1), vecType<L, T, P>(1), FirstQuarterPi));
vecType<L, T, P> const SectionAngle(RevertAngle - Angle0_PI);
vec<L, T, P> const RevertAngle(mix(vec<L, T, P>(glm::pi<T>()), vec<L, T, P>(0), FirstQuarterPi));
vec<L, T, P> const ReturnSign(mix(vec<L, T, P>(-1), vec<L, T, P>(1), FirstQuarterPi));
vec<L, T, P> const SectionAngle(RevertAngle - Angle0_PI);
return ReturnSign * taylorSeriesNewCos(SectionAngle);
*/
@@ -254,21 +254,21 @@ namespace taylorCos
return Error;
}
template<glm::length_t L, typename T, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> deterministic_fmod(vecType<L, T, P> const & x, T y)
template<glm::length_t L, typename T, qualifier P>
GLM_FUNC_QUALIFIER glm::vec<L, T, P> deterministic_fmod(glm::vec<L, T, P> const & x, T y)
{
return x - y * trunc(x / y);
}
template<glm::length_t L, typename T, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> fastCosDeterminisctic(vecType<L, T, P> const & x)
template<glm::length_t L, typename T, qualifier P>
GLM_FUNC_QUALIFIER glm::vec<L, T, P> fastCosDeterminisctic(glm::vec<L, T, P> const & x)
{
vecType<L, T, P> const Angle0_PI(abs(deterministic_fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
vecType<L, bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType<L, T, P>(glm::half_pi<T>())));
glm::vec<L, T, P> const Angle0_PI(abs(deterministic_fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
glm::vec<L, bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, glm::vec<L, T, P>(glm::half_pi<T>())));
vecType<L, T, P> const RevertAngle(mix(vecType<L, T, P>(glm::pi<T>()), vecType<L, T, P>(0), FirstQuarterPi));
vecType<L, T, P> const ReturnSign(mix(vecType<L, T, P>(-1), vecType<L, T, P>(1), FirstQuarterPi));
vecType<L, T, P> const SectionAngle(RevertAngle - Angle0_PI);
glm::vec<L, T, P> const RevertAngle(mix(glm::vec<L, T, P>(glm::pi<T>()), glm::vec<L, T, P>(0), FirstQuarterPi));
glm::vec<L, T, P> const ReturnSign(mix(glm::vec<L, T, P>(-1), glm::vec<L, T, P>(1), FirstQuarterPi));
glm::vec<L, T, P> const SectionAngle(RevertAngle - Angle0_PI);
return ReturnSign * taylorSeriesNewCos(SectionAngle);
}
@@ -295,8 +295,8 @@ namespace taylorCos
return Error;
}
template<glm::length_t L, typename T, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> taylorSeriesRefCos(vecType<L, T, P> const & x)
template<glm::length_t L, typename T, qualifier P>
GLM_FUNC_QUALIFIER glm::vec<L, T, P> taylorSeriesRefCos(glm::vec<L, T, P> const & x)
{
return static_cast<T>(1)
- (x * x) / glm::factorial(static_cast<T>(2))
@@ -305,17 +305,17 @@ namespace taylorCos
+ (x * x * x * x * x * x * x * x) / glm::factorial(static_cast<T>(8));
}
template<glm::length_t L, typename T, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> fastRefCos(vecType<L, T, P> const & x)
template<glm::length_t L, typename T, qualifier P>
GLM_FUNC_QUALIFIER glm::vec<L, T, P> fastRefCos(glm::vec<L, T, P> const & x)
{
vecType<L, T, P> const Angle0_PI(glm::abs(fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
glm::vec<L, T, P> const Angle0_PI(glm::abs(fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
// return taylorSeriesRefCos(Angle0_PI);
vecType<L, bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType<L, T, P>(glm::half_pi<T>())));
glm::vec<L, bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, glm::vec<L, T, P>(glm::half_pi<T>())));
vecType<L, T, P> const RevertAngle(mix(vecType<L, T, P>(glm::pi<T>()), vecType<L, T, P>(0), FirstQuarterPi));
vecType<L, T, P> const ReturnSign(mix(vecType<L, T, P>(-1), vecType<L, T, P>(1), FirstQuarterPi));
vecType<L, T, P> const SectionAngle(RevertAngle - Angle0_PI);
glm::vec<L, T, P> const RevertAngle(mix(glm::vec<L, T, P>(glm::pi<T>()), glm::vec<L, T, P>(0), FirstQuarterPi));
glm::vec<L, T, P> const ReturnSign(mix(glm::vec<L, T, P>(-1), glm::vec<L, T, P>(1), FirstQuarterPi));
glm::vec<L, T, P> const SectionAngle(RevertAngle - Angle0_PI);
return ReturnSign * taylorSeriesRefCos(SectionAngle);
}

View File

@@ -8,7 +8,7 @@
namespace
{
template<typename CTy, typename CTr>
std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, glm::precision const& a)
std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, glm::qualifier const& a)
{
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
@@ -29,7 +29,7 @@ namespace
return os;
}
template<typename U, glm::precision P, typename T, typename CTy, typename CTr>
template<typename U, glm::qualifier P, typename T, typename CTy, typename CTr>
std::basic_string<CTy> type_name(std::basic_ostream<CTy,CTr>&, T const&)
{
std::basic_ostringstream<CTy,CTr> ostr;
@@ -55,7 +55,7 @@ namespace
}
} // namespace {
template<typename T, glm::precision P, typename OS>
template<typename T, glm::qualifier P, typename OS>
int test_io_quat(OS& os)
{
os << '\n' << typeid(OS).name() << '\n';
@@ -79,7 +79,7 @@ int test_io_quat(OS& os)
return 0;
}
template<typename T, glm::precision P, typename OS>
template<typename T, glm::qualifier P, typename OS>
int test_io_vec(OS& os)
{
os << '\n' << typeid(OS).name() << '\n';
@@ -102,7 +102,7 @@ int test_io_vec(OS& os)
return 0;
}
template<typename T, glm::precision P, typename OS>
template<typename T, glm::qualifier P, typename OS>
int test_io_mat(OS& os, glm::io::order_type otype)
{
os << '\n' << typeid(OS).name() << '\n';

View File

@@ -3,7 +3,7 @@
#include <glm/gtc/constants.hpp>
#include <glm/gtc/epsilon.hpp>
template <glm::length_t C, glm::length_t R, typename T, glm::precision P, template<glm::length_t, glm::length_t, typename, glm::precision> class matType>
template <glm::length_t C, glm::length_t R, typename T, glm::qualifier P, template<glm::length_t, glm::length_t, typename, glm::qualifier> class matType>
int test_qr(matType<C, R, T, P> m)
{
int Error = 0;
@@ -40,7 +40,7 @@ int test_qr(matType<C, R, T, P> m)
return Error;
}
template <glm::length_t C, glm::length_t R, typename T, glm::precision P, template<glm::length_t, glm::length_t, typename, glm::precision> class matType>
template <glm::length_t C, glm::length_t R, typename T, glm::qualifier P, template<glm::length_t, glm::length_t, typename, glm::qualifier> class matType>
int test_rq(matType<C, R, T, P> m)
{
int Error = 0;