Added EXT_scalar_common, EXT_vector_common and EXT_quaternion_exponential extensions
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
glmCreateTestGTC(ext_matrix_relational)
|
||||
glmCreateTestGTC(ext_matrix_transform)
|
||||
glmCreateTestGTC(ext_quaternion_common)
|
||||
glmCreateTestGTC(ext_quaternion_exponential)
|
||||
glmCreateTestGTC(ext_quaternion_geometric)
|
||||
glmCreateTestGTC(ext_quaternion_relational)
|
||||
glmCreateTestGTC(ext_quaternion_transform)
|
||||
glmCreateTestGTC(ext_quaternion_trigonometric)
|
||||
glmCreateTestGTC(ext_quaternion_type)
|
||||
glmCreateTestGTC(ext_scalar_common)
|
||||
glmCreateTestGTC(ext_scalar_constants)
|
||||
glmCreateTestGTC(ext_scalar_float_sized)
|
||||
glmCreateTestGTC(ext_scalar_int_sized)
|
||||
@@ -13,6 +15,7 @@ glmCreateTestGTC(ext_scalar_uint_sized)
|
||||
glmCreateTestGTC(ext_scalar_relational)
|
||||
glmCreateTestGTC(ext_vec1)
|
||||
glmCreateTestGTC(ext_vector_bool1)
|
||||
glmCreateTestGTC(ext_vector_common)
|
||||
glmCreateTestGTC(ext_vector_iec559)
|
||||
glmCreateTestGTC(ext_vector_integer)
|
||||
glmCreateTestGTC(ext_vector_relational)
|
||||
|
||||
87
test/ext/ext_quaternion_exponential.cpp
Normal file
87
test/ext/ext_quaternion_exponential.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include <glm/ext/quaternion_exponential.hpp>
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/quaternion_float_precision.hpp>
|
||||
#include <glm/ext/quaternion_double.hpp>
|
||||
#include <glm/ext/quaternion_double_precision.hpp>
|
||||
#include <glm/ext/quaternion_relational.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float3_precision.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double3_precision.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
|
||||
template <typename quaType, typename vecType>
|
||||
int test_log()
|
||||
{
|
||||
typedef typename quaType::value_type T;
|
||||
|
||||
T const Epsilon = static_cast<T>(0.001f);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
quaType const Q(vecType(1, 0, 0), vecType(0, 1, 0));
|
||||
quaType const P = glm::log(Q);
|
||||
Error += glm::any(glm::notEqual(Q, P, Epsilon)) ? 0 : 1;
|
||||
|
||||
quaType const R = glm::exp(P);
|
||||
Error += glm::all(glm::equal(Q, R, Epsilon)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename quaType, typename vecType>
|
||||
int test_pow()
|
||||
{
|
||||
typedef typename quaType::value_type T;
|
||||
|
||||
T const Epsilon = static_cast<T>(0.001f);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
quaType const Q(vecType(1, 0, 0), vecType(0, 1, 0));
|
||||
|
||||
{
|
||||
T const One = static_cast<T>(1.0f);
|
||||
quaType const P = glm::pow(Q, One);
|
||||
Error += glm::all(glm::equal(Q, P, Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
T const Two = static_cast<T>(2.0f);
|
||||
quaType const P = glm::pow(Q, Two);
|
||||
quaType const R = Q * Q;
|
||||
Error += glm::all(glm::equal(P, R, Epsilon)) ? 0 : 1;
|
||||
|
||||
quaType const U = glm::sqrt(P);
|
||||
Error += glm::all(glm::equal(Q, U, Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_log<glm::quat, glm::vec3>();
|
||||
Error += test_log<glm::lowp_quat, glm::lowp_vec3>();
|
||||
Error += test_log<glm::mediump_quat, glm::mediump_vec3>();
|
||||
Error += test_log<glm::highp_quat, glm::highp_vec3>();
|
||||
|
||||
Error += test_log<glm::dquat, glm::dvec3>();
|
||||
Error += test_log<glm::lowp_dquat, glm::lowp_dvec3>();
|
||||
Error += test_log<glm::mediump_dquat, glm::mediump_dvec3>();
|
||||
Error += test_log<glm::highp_dquat, glm::highp_dvec3>();
|
||||
|
||||
Error += test_pow<glm::quat, glm::vec3>();
|
||||
Error += test_pow<glm::lowp_quat, glm::lowp_vec3>();
|
||||
Error += test_pow<glm::mediump_quat, glm::mediump_vec3>();
|
||||
Error += test_pow<glm::highp_quat, glm::highp_vec3>();
|
||||
|
||||
Error += test_pow<glm::dquat, glm::dvec3>();
|
||||
Error += test_pow<glm::lowp_dquat, glm::lowp_dvec3>();
|
||||
Error += test_pow<glm::mediump_dquat, glm::mediump_dvec3>();
|
||||
Error += test_pow<glm::highp_dquat, glm::highp_dvec3>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
@@ -3,9 +3,43 @@
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
static int test_lookAt()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::vec3 eye(0.0f);
|
||||
glm::vec3 center(1.1f, -2.0f, 3.1416f);
|
||||
glm::vec3 up(-0.17f, 7.23f, -1.744f);
|
||||
|
||||
glm::quat test_quat = glm::quatLookAt(glm::normalize(center - eye), up);
|
||||
glm::quat test_mat = glm::conjugate(glm::quat_cast(glm::lookAt(eye, center, up)));
|
||||
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quat) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quat + (-test_mat)), glm::length(test_quat + test_mat)) > glm::epsilon<float>());
|
||||
|
||||
// Test left-handed implementation
|
||||
glm::quat test_quatLH = glm::quatLookAtLH(glm::normalize(center - eye), up);
|
||||
glm::quat test_matLH = glm::conjugate(glm::quat_cast(glm::lookAtLH(eye, center, up)));
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quatLH) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quatLH - test_matLH), glm::length(test_quatLH + test_matLH)) > glm::epsilon<float>());
|
||||
|
||||
// Test right-handed implementation
|
||||
glm::quat test_quatRH = glm::quatLookAtRH(glm::normalize(center - eye), up);
|
||||
glm::quat test_matRH = glm::conjugate(glm::quat_cast(glm::lookAtRH(eye, center, up)));
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quatRH) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quatRH - test_matRH), glm::length(test_quatRH + test_matRH)) > glm::epsilon<float>());
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_lookAt();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
204
test/ext/ext_scalar_common.cpp
Normal file
204
test/ext/ext_scalar_common.cpp
Normal file
@@ -0,0 +1,204 @@
|
||||
#include <glm/ext/scalar_common.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/common.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
template <typename T>
|
||||
static int test_min()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const N = static_cast<T>(0);
|
||||
T const B = static_cast<T>(1);
|
||||
Error += glm::equal(glm::min(N, B), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, N), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::equal(glm::min(N, B, C), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, N, C), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(C, N, B), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(C, B, N), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, C, N), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(N, C, B), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += glm::equal(glm::min(D, N, B, C), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, D, N, C), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(C, N, D, B), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(C, B, D, N), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, C, N, D), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(N, C, B, D), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_min_nan()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const A = static_cast<T>(0);
|
||||
T const B = static_cast<T>(1);
|
||||
T const N = A / A;
|
||||
Error += glm::isnan(glm::min(N, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, N)) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::isnan(glm::min(N, B, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, N, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(C, N, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(C, B, N)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, C, N)) ? 0 : 1;
|
||||
Error += glm::isnan(glm::min(N, C, B)) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += !glm::isnan(glm::min(D, N, B, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, D, N, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(C, N, D, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(C, B, D, N)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, C, N, D)) ? 0 : 1;
|
||||
Error += glm::isnan(glm::min(N, C, B, D)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_max()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const N = static_cast<T>(0);
|
||||
T const B = static_cast<T>(1);
|
||||
Error += glm::equal(glm::max(N, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, N), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::equal(glm::max(N, B, C), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, N, C), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(C, N, B), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(C, B, N), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, C, N), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(N, C, B), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += glm::equal(glm::max(D, N, B, C), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, D, N, C), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(C, N, D, B), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(C, B, D, N), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, C, N, D), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(N, C, B, D), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_max_nan()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const A = static_cast<T>(0);
|
||||
T const B = static_cast<T>(1);
|
||||
T const N = A / A;
|
||||
Error += glm::isnan(glm::max(N, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, N)) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::isnan(glm::max(N, B, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, N, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(C, N, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(C, B, N)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, C, N)) ? 0 : 1;
|
||||
Error += glm::isnan(glm::max(N, C, B)) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += !glm::isnan(glm::max(D, N, B, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, D, N, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(C, N, D, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(C, B, D, N)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, C, N, D)) ? 0 : 1;
|
||||
Error += glm::isnan(glm::max(N, C, B, D)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_fmin()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const A = static_cast<T>(0);
|
||||
T const B = static_cast<T>(1);
|
||||
Error += glm::equal(glm::fmin(A / A, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, A / A), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::equal(glm::fmin(A / A, B, C), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, A / A, C), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(C, A / A, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(C, B, A / A), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, C, A / A), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(A / A, C, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += glm::equal(glm::fmin(D, A / A, B, C), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, D, A / A, C), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(C, A / A, D, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(C, B, D, A / A), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, C, A / A, D), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(A / A, C, B, D), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_fmax()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const A = static_cast<T>(0);
|
||||
T const B = static_cast<T>(1);
|
||||
Error += glm::equal(glm::fmax(A / A, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, A / A), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::equal(glm::fmax(A / A, B, C), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, A / A, C), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(C, A / A, B), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(C, B, A / A), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, C, A / A), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(A / A, C, B), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += glm::equal(glm::fmax(D, A / A, B, C), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, D, A / A, C), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(C, A / A, D, B), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(C, B, D, A / A), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, C, A / A, D), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(A / A, C, B, D), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_min<float>();
|
||||
Error += test_min<double>();
|
||||
Error += test_min_nan<float>();
|
||||
Error += test_min_nan<double>();
|
||||
|
||||
Error += test_max<float>();
|
||||
Error += test_max<double>();
|
||||
Error += test_max_nan<float>();
|
||||
Error += test_max_nan<double>();
|
||||
|
||||
Error += test_fmin<float>();
|
||||
Error += test_fmin<double>();
|
||||
|
||||
Error += test_fmax<float>();
|
||||
Error += test_fmax<double>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
24
test/ext/ext_vector_common.cpp
Normal file
24
test/ext/ext_vector_common.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <glm/ext/vector_common.hpp>
|
||||
#include <glm/ext/vector_float1.hpp>
|
||||
#include <glm/ext/vector_float1_precision.hpp>
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float2_precision.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float3_precision.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/vector_float4_precision.hpp>
|
||||
#include <glm/ext/vector_double1.hpp>
|
||||
#include <glm/ext/vector_double1_precision.hpp>
|
||||
#include <glm/ext/vector_double2.hpp>
|
||||
#include <glm/ext/vector_double2_precision.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double3_precision.hpp>
|
||||
#include <glm/ext/vector_double4.hpp>
|
||||
#include <glm/ext/vector_double4_precision.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
Reference in New Issue
Block a user