2018-07-28 19:06:00 +00:00
|
|
|
|
#include <glm/gtc/constants.hpp>
|
2011-05-08 00:08:16 +00:00
|
|
|
|
#include <glm/gtc/quaternion.hpp>
|
2018-07-26 16:00:31 +00:00
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
2018-07-25 21:27:57 +00:00
|
|
|
|
#include <glm/ext/vector_relational.hpp>
|
|
|
|
|
#include <glm/glm.hpp>
|
2014-02-08 18:08:09 +00:00
|
|
|
|
#include <vector>
|
2012-04-07 01:30:26 +00:00
|
|
|
|
|
|
|
|
|
int test_quat_angle()
|
|
|
|
|
{
|
2012-12-13 21:48:20 +00:00
|
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
|
|
{
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
glm::quat N = glm::normalize(Q);
|
|
|
|
|
float L = glm::length(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(L, 1.0f, 0.01f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
float A = glm::angle(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::normalize(glm::vec3(0, 1, 1)));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
glm::quat N = glm::normalize(Q);
|
|
|
|
|
float L = glm::length(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(L, 1.0f, 0.01f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
float A = glm::angle(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::normalize(glm::vec3(1, 2, 3)));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
glm::quat N = glm::normalize(Q);
|
|
|
|
|
float L = glm::length(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(L, 1.0f, 0.01f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
float A = glm::angle(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Error;
|
2012-04-07 01:30:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_quat_angleAxis()
|
|
|
|
|
{
|
|
|
|
|
int Error = 0;
|
|
|
|
|
|
2017-08-15 13:12:04 +00:00
|
|
|
|
glm::quat A = glm::angleAxis(0.f, glm::vec3(0.f, 0.f, 1.f));
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat B = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
glm::quat C = glm::mix(A, B, 0.5f);
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat D = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
|
2012-04-07 01:30:26 +00:00
|
|
|
|
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(C.x, D.x, 0.01f) ? 0 : 1;
|
|
|
|
|
Error += glm::equal(C.y, D.y, 0.01f) ? 0 : 1;
|
|
|
|
|
Error += glm::equal(C.z, D.z, 0.01f) ? 0 : 1;
|
|
|
|
|
Error += glm::equal(C.w, D.w, 0.01f) ? 0 : 1;
|
2012-04-07 01:30:26 +00:00
|
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_quat_mix()
|
|
|
|
|
{
|
|
|
|
|
int Error = 0;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
|
2017-08-15 13:12:04 +00:00
|
|
|
|
glm::quat A = glm::angleAxis(0.f, glm::vec3(0.f, 0.f, 1.f));
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat B = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
glm::quat C = glm::mix(A, B, 0.5f);
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat D = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(C.x, D.x, 0.01f) ? 0 : 1;
|
|
|
|
|
Error += glm::equal(C.y, D.y, 0.01f) ? 0 : 1;
|
|
|
|
|
Error += glm::equal(C.z, D.z, 0.01f) ? 0 : 1;
|
|
|
|
|
Error += glm::equal(C.w, D.w, 0.01f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
|
2012-04-07 01:30:26 +00:00
|
|
|
|
return Error;
|
|
|
|
|
}
|
2011-05-25 08:50:01 +00:00
|
|
|
|
|
2011-05-31 15:46:13 +00:00
|
|
|
|
int test_quat_precision()
|
|
|
|
|
{
|
|
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
|
|
Error += sizeof(glm::lowp_quat) <= sizeof(glm::mediump_quat) ? 0 : 1;
|
|
|
|
|
Error += sizeof(glm::mediump_quat) <= sizeof(glm::highp_quat) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
|
|
|
|
|
return Error;
|
2011-05-31 15:46:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-07 01:30:26 +00:00
|
|
|
|
int test_quat_normalize()
|
|
|
|
|
{
|
2012-12-13 21:48:20 +00:00
|
|
|
|
int Error(0);
|
|
|
|
|
|
|
|
|
|
{
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
glm::quat N = glm::normalize(Q);
|
|
|
|
|
float L = glm::length(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(L, 1.0f, 0.000001f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 2));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
glm::quat N = glm::normalize(Q);
|
|
|
|
|
float L = glm::length(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(L, 1.0f, 0.000001f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
2014-01-11 20:12:53 +00:00
|
|
|
|
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(1, 2, 3));
|
2012-12-13 21:48:20 +00:00
|
|
|
|
glm::quat N = glm::normalize(Q);
|
|
|
|
|
float L = glm::length(N);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(L, 1.0f, 0.000001f) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_quat_euler()
|
|
|
|
|
{
|
2017-08-17 17:51:03 +00:00
|
|
|
|
int Error = 0;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
glm::quat q(1.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
float Roll = glm::roll(q);
|
|
|
|
|
float Pitch = glm::pitch(q);
|
|
|
|
|
float Yaw = glm::yaw(q);
|
|
|
|
|
glm::vec3 Angles = glm::eulerAngles(q);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(Angles, glm::vec3(Pitch, Yaw, Roll), 0.000001f)) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2017-08-09 20:40:33 +00:00
|
|
|
|
glm::dquat q(1.0, 0.0, 0.0, 1.0);
|
2012-12-13 21:48:20 +00:00
|
|
|
|
double Roll = glm::roll(q);
|
|
|
|
|
double Pitch = glm::pitch(q);
|
|
|
|
|
double Yaw = glm::yaw(q);
|
|
|
|
|
glm::dvec3 Angles = glm::eulerAngles(q);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(Angles, glm::dvec3(Pitch, Yaw, Roll), 0.000001)) ? 0 : 1;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Error;
|
2012-04-07 01:30:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-21 23:32:07 +00:00
|
|
|
|
int test_quat_slerp()
|
|
|
|
|
{
|
2017-08-17 17:51:03 +00:00
|
|
|
|
int Error = 0;
|
2012-12-21 23:32:07 +00:00
|
|
|
|
|
|
|
|
|
float const Epsilon = 0.0001f;//glm::epsilon<float>();
|
|
|
|
|
|
2017-08-08 18:28:37 +00:00
|
|
|
|
float sqrt2 = std::sqrt(2.0f)/2.0f;
|
2017-07-25 20:15:55 +00:00
|
|
|
|
glm::quat id(static_cast<float>(1), static_cast<float>(0), static_cast<float>(0), static_cast<float>(0));
|
2012-12-21 23:32:07 +00:00
|
|
|
|
glm::quat Y90rot(sqrt2, 0.0f, sqrt2, 0.0f);
|
|
|
|
|
glm::quat Y180rot(0.0f, 0.0f, 1.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
// Testing a == 0
|
|
|
|
|
// Must be id
|
|
|
|
|
glm::quat id2 = glm::slerp(id, Y90rot, 0.0f);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(id, id2, Epsilon)) ? 0 : 1;
|
2012-12-21 23:32:07 +00:00
|
|
|
|
|
|
|
|
|
// Testing a == 1
|
|
|
|
|
// Must be 90<39> rotation on Y : 0 0.7 0 0.7
|
|
|
|
|
glm::quat Y90rot2 = glm::slerp(id, Y90rot, 1.0f);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(Y90rot, Y90rot2, Epsilon)) ? 0 : 1;
|
2012-12-21 23:32:07 +00:00
|
|
|
|
|
|
|
|
|
// Testing standard, easy case
|
|
|
|
|
// Must be 45<34> rotation on Y : 0 0.38 0 0.92
|
|
|
|
|
glm::quat Y45rot1 = glm::slerp(id, Y90rot, 0.5f);
|
|
|
|
|
|
|
|
|
|
// Testing reverse case
|
|
|
|
|
// Must be 45<34> rotation on Y : 0 0.38 0 0.92
|
|
|
|
|
glm::quat Ym45rot2 = glm::slerp(Y90rot, id, 0.5f);
|
|
|
|
|
|
|
|
|
|
// Testing against full circle around the sphere instead of shortest path
|
|
|
|
|
// Must be 45<34> rotation on Y
|
|
|
|
|
// certainly not a 135<33> rotation
|
|
|
|
|
glm::quat Y45rot3 = glm::slerp(id , -Y90rot, 0.5f);
|
|
|
|
|
float Y45angle3 = glm::angle(Y45rot3);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(Y45angle3, glm::pi<float>() * 0.25f, Epsilon) ? 0 : 1;
|
|
|
|
|
Error += glm::all(glm::equal(Ym45rot2, Y45rot3, Epsilon)) ? 0 : 1;
|
2012-12-21 23:32:07 +00:00
|
|
|
|
|
|
|
|
|
// Same, but inverted
|
|
|
|
|
// Must also be 45<34> rotation on Y : 0 0.38 0 0.92
|
|
|
|
|
// -0 -0.38 -0 -0.92 is ok too
|
|
|
|
|
glm::quat Y45rot4 = glm::slerp(-Y90rot, id, 0.5f);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(Ym45rot2, -Y45rot4, Epsilon)) ? 0 : 1;
|
2012-12-21 23:32:07 +00:00
|
|
|
|
|
|
|
|
|
// Testing q1 = q2
|
|
|
|
|
// Must be 90<39> rotation on Y : 0 0.7 0 0.7
|
|
|
|
|
glm::quat Y90rot3 = glm::slerp(Y90rot, Y90rot, 0.5f);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(Y90rot, Y90rot3, Epsilon)) ? 0 : 1;
|
2012-12-21 23:32:07 +00:00
|
|
|
|
|
|
|
|
|
// Testing 180<38> rotation
|
|
|
|
|
// Must be 90<39> rotation on almost any axis that is on the XZ plane
|
|
|
|
|
glm::quat XZ90rot = glm::slerp(id, -Y90rot, 0.5f);
|
|
|
|
|
float XZ90angle = glm::angle(XZ90rot); // Must be PI/4 = 0.78;
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(XZ90angle, glm::pi<float>() * 0.25f, Epsilon) ? 0 : 1;
|
2012-12-21 23:32:07 +00:00
|
|
|
|
|
|
|
|
|
// Testing almost equal quaternions (this test should pass through the linear interpolation)
|
|
|
|
|
// Must be 0 0.00X 0 0.99999
|
2013-04-15 09:04:24 +00:00
|
|
|
|
glm::quat almostid = glm::slerp(id, glm::angleAxis(0.1f, glm::vec3(0.0f, 1.0f, 0.0f)), 0.5f);
|
2012-12-21 23:32:07 +00:00
|
|
|
|
|
2014-06-05 15:48:53 +00:00
|
|
|
|
// Testing quaternions with opposite sign
|
|
|
|
|
{
|
|
|
|
|
glm::quat a(-1, 0, 0, 0);
|
|
|
|
|
|
|
|
|
|
glm::quat result = glm::slerp(a, id, 0.5f);
|
|
|
|
|
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::equal(glm::pow(glm::dot(id, result), 2.f), 1.f, 0.01f) ? 0 : 1;
|
2014-06-05 15:48:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-21 23:32:07 +00:00
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-29 17:44:59 +00:00
|
|
|
|
int test_quat_mul()
|
|
|
|
|
{
|
2018-07-09 22:06:28 +00:00
|
|
|
|
int Error = 0;
|
2013-09-29 17:44:59 +00:00
|
|
|
|
|
|
|
|
|
glm::quat temp1 = glm::normalize(glm::quat(1.0f, glm::vec3(0.0, 1.0, 0.0)));
|
|
|
|
|
glm::quat temp2 = glm::normalize(glm::quat(0.5f, glm::vec3(1.0, 0.0, 0.0)));
|
|
|
|
|
|
|
|
|
|
glm::vec3 transformed0 = (temp1 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp1));
|
|
|
|
|
glm::vec3 temp4 = temp2 * transformed0 * glm::inverse(temp2);
|
|
|
|
|
|
|
|
|
|
glm::quat temp5 = glm::normalize(temp1 * temp2);
|
|
|
|
|
glm::vec3 temp6 = temp5 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp5);
|
|
|
|
|
|
2017-07-25 20:15:55 +00:00
|
|
|
|
glm::quat temp7(1.0f, glm::vec3(0.0, 1.0, 0.0));
|
2014-01-11 20:12:53 +00:00
|
|
|
|
|
2017-07-25 20:15:55 +00:00
|
|
|
|
temp7 *= temp5;
|
|
|
|
|
temp7 *= glm::inverse(temp5);
|
2013-11-22 21:46:30 +00:00
|
|
|
|
|
2017-07-25 20:15:55 +00:00
|
|
|
|
Error += temp7 != glm::quat(1.0f, glm::vec3(0.0, 1.0, 0.0));
|
2013-11-22 21:46:30 +00:00
|
|
|
|
|
2013-09-29 17:44:59 +00:00
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int test_quat_two_axis_ctr()
|
|
|
|
|
{
|
2017-08-22 20:47:36 +00:00
|
|
|
|
int Error = 0;
|
2013-09-29 17:44:59 +00:00
|
|
|
|
|
2017-08-22 20:47:36 +00:00
|
|
|
|
glm::quat const q1(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
|
|
|
|
glm::vec3 const v1 = q1 * glm::vec3(1, 0, 0);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(v1, glm::vec3(0, 1, 0), 0.0001f)) ? 0 : 1;
|
2013-09-29 17:44:59 +00:00
|
|
|
|
|
2017-08-22 20:47:36 +00:00
|
|
|
|
glm::quat const q2 = q1 * q1;
|
|
|
|
|
glm::vec3 const v2 = q2 * glm::vec3(1, 0, 0);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(v2, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
|
2013-09-29 17:44:59 +00:00
|
|
|
|
|
2017-08-22 20:47:36 +00:00
|
|
|
|
glm::quat const q3(glm::vec3(1, 0, 0), glm::vec3(-1, 0, 0));
|
|
|
|
|
glm::vec3 const v3 = q3 * glm::vec3(1, 0, 0);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(v3, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
|
2017-08-22 20:47:36 +00:00
|
|
|
|
|
|
|
|
|
glm::quat const q4(glm::vec3(0, 1, 0), glm::vec3(0, -1, 0));
|
|
|
|
|
glm::vec3 const v4 = q4 * glm::vec3(0, 1, 0);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(v4, glm::vec3(0, -1, 0), 0.0001f)) ? 0 : 1;
|
2017-08-22 20:47:36 +00:00
|
|
|
|
|
|
|
|
|
glm::quat const q5(glm::vec3(0, 0, 1), glm::vec3(0, 0, -1));
|
|
|
|
|
glm::vec3 const v5 = q5 * glm::vec3(0, 0, 1);
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(v5, glm::vec3(0, 0, -1), 0.0001f)) ? 0 : 1;
|
2017-08-22 20:47:36 +00:00
|
|
|
|
|
2013-09-29 17:44:59 +00:00
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-11 22:29:56 +00:00
|
|
|
|
int test_quat_mul_vec()
|
|
|
|
|
{
|
2014-06-19 21:05:35 +00:00
|
|
|
|
int Error(0);
|
|
|
|
|
|
2014-06-11 22:29:56 +00:00
|
|
|
|
glm::quat q = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
|
|
|
|
|
glm::vec3 v(1, 0, 0);
|
|
|
|
|
glm::vec3 u(q * v);
|
|
|
|
|
glm::vec3 w(u * q);
|
|
|
|
|
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(v, w, 0.01f)) ? 0 : 1;
|
2014-06-19 21:05:35 +00:00
|
|
|
|
|
|
|
|
|
return Error;
|
2014-06-11 22:29:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-08 18:08:09 +00:00
|
|
|
|
int test_quat_ctr()
|
|
|
|
|
{
|
|
|
|
|
int Error(0);
|
|
|
|
|
|
2014-11-15 20:59:46 +00:00
|
|
|
|
# if GLM_HAS_TRIVIAL_QUERIES
|
|
|
|
|
// Error += std::is_trivially_default_constructible<glm::quat>::value ? 0 : 1;
|
|
|
|
|
// Error += std::is_trivially_default_constructible<glm::dquat>::value ? 0 : 1;
|
|
|
|
|
// Error += std::is_trivially_copy_assignable<glm::quat>::value ? 0 : 1;
|
|
|
|
|
// Error += std::is_trivially_copy_assignable<glm::dquat>::value ? 0 : 1;
|
|
|
|
|
Error += std::is_trivially_copyable<glm::quat>::value ? 0 : 1;
|
|
|
|
|
Error += std::is_trivially_copyable<glm::dquat>::value ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
Error += std::is_copy_constructible<glm::quat>::value ? 0 : 1;
|
|
|
|
|
Error += std::is_copy_constructible<glm::dquat>::value ? 0 : 1;
|
|
|
|
|
# endif
|
2014-11-14 23:05:52 +00:00
|
|
|
|
|
2014-10-11 23:24:28 +00:00
|
|
|
|
# if GLM_HAS_INITIALIZER_LISTS
|
2014-02-08 18:08:09 +00:00
|
|
|
|
{
|
|
|
|
|
glm::quat A{0, 1, 2, 3};
|
|
|
|
|
|
|
|
|
|
std::vector<glm::quat> B{
|
|
|
|
|
{0, 1, 2, 3},
|
|
|
|
|
{0, 1, 2, 3}};
|
|
|
|
|
}
|
|
|
|
|
# endif//GLM_HAS_INITIALIZER_LISTS
|
|
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 08:14:28 +00:00
|
|
|
|
int test_size()
|
|
|
|
|
{
|
|
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
|
|
Error += 16 == sizeof(glm::quat) ? 0 : 1;
|
|
|
|
|
Error += 32 == sizeof(glm::dquat) ? 0 : 1;
|
|
|
|
|
Error += glm::quat().length() == 4 ? 0 : 1;
|
|
|
|
|
Error += glm::dquat().length() == 4 ? 0 : 1;
|
|
|
|
|
Error += glm::quat::length() == 4 ? 0 : 1;
|
|
|
|
|
Error += glm::dquat::length() == 4 ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-09 22:06:28 +00:00
|
|
|
|
static int test_constexpr()
|
|
|
|
|
{
|
2018-07-24 21:41:55 +00:00
|
|
|
|
#if GLM_HAS_CONSTEXPR
|
2018-07-09 22:06:28 +00:00
|
|
|
|
static_assert(glm::quat::length() == 4, "GLM: Failed constexpr");
|
|
|
|
|
static_assert(glm::quat(1.0f, glm::vec3(0.0f)).w > 0.0f, "GLM: Failed constexpr");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-25 20:16:16 +00:00
|
|
|
|
int test_identity()
|
|
|
|
|
{
|
|
|
|
|
int Error = 0;
|
|
|
|
|
|
2018-07-26 16:00:31 +00:00
|
|
|
|
glm::quat const Q = glm::identity<glm::quat>();
|
2018-07-25 20:16:16 +00:00
|
|
|
|
|
|
|
|
|
Error += glm::all(glm::equal(Q, glm::quat(1, 0, 0, 0), 0.0001f)) ? 0 : 1;
|
|
|
|
|
Error += glm::any(glm::notEqual(Q, glm::quat(1, 0, 0, 0), 0.0001f)) ? 1 : 0;
|
|
|
|
|
|
2018-07-26 16:00:31 +00:00
|
|
|
|
glm::mat4 const M = glm::identity<glm::mat4x4>();
|
2018-07-25 21:27:57 +00:00
|
|
|
|
glm::mat4 const N(1.0f);
|
|
|
|
|
|
2018-07-28 19:06:00 +00:00
|
|
|
|
Error += glm::all(glm::equal(M, N, 0.0001f)) ? 0 : 1;
|
2018-07-25 21:27:57 +00:00
|
|
|
|
|
2018-07-25 20:16:16 +00:00
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-24 15:44:14 +00:00
|
|
|
|
int main()
|
2011-01-20 11:02:39 +00:00
|
|
|
|
{
|
2016-11-01 08:14:28 +00:00
|
|
|
|
int Error = 0;
|
2012-12-13 21:48:20 +00:00
|
|
|
|
|
2014-02-08 18:08:09 +00:00
|
|
|
|
Error += test_quat_ctr();
|
2014-06-11 22:29:56 +00:00
|
|
|
|
Error += test_quat_mul_vec();
|
2013-09-29 17:44:59 +00:00
|
|
|
|
Error += test_quat_two_axis_ctr();
|
|
|
|
|
Error += test_quat_mul();
|
2011-05-31 15:46:13 +00:00
|
|
|
|
Error += test_quat_precision();
|
2012-12-13 21:48:20 +00:00
|
|
|
|
Error += test_quat_angle();
|
2012-04-07 01:30:26 +00:00
|
|
|
|
Error += test_quat_angleAxis();
|
|
|
|
|
Error += test_quat_mix();
|
|
|
|
|
Error += test_quat_normalize();
|
2012-12-13 21:48:20 +00:00
|
|
|
|
Error += test_quat_euler();
|
2012-12-21 23:32:07 +00:00
|
|
|
|
Error += test_quat_slerp();
|
2016-11-01 08:14:28 +00:00
|
|
|
|
Error += test_size();
|
2018-07-09 22:06:28 +00:00
|
|
|
|
Error += test_constexpr();
|
2018-07-25 20:16:16 +00:00
|
|
|
|
Error += test_identity();
|
2011-01-20 11:02:39 +00:00
|
|
|
|
|
2011-05-02 22:38:55 +00:00
|
|
|
|
return Error;
|
2011-01-20 11:02:39 +00:00
|
|
|
|
}
|