2016-11-12 13:19:22 +00:00
|
|
|
#define GLM_ENABLE_EXPERIMENTAL
|
2014-08-31 22:12:38 +00:00
|
|
|
#include <glm/gtx/matrix_decompose.hpp>
|
|
|
|
|
2024-01-20 09:11:13 +00:00
|
|
|
#include <glm/ext/matrix_relational.hpp>
|
|
|
|
#include <glm/ext/matrix_transform.hpp>
|
|
|
|
#include <glm/ext/scalar_constants.hpp>
|
|
|
|
|
|
|
|
static int test_identity() {
|
|
|
|
int Error = 0;
|
2014-08-31 22:12:38 +00:00
|
|
|
|
2015-08-01 09:35:57 +00:00
|
|
|
glm::mat4 Matrix(1);
|
|
|
|
|
|
|
|
glm::vec3 Scale;
|
|
|
|
glm::quat Orientation;
|
|
|
|
glm::vec3 Translation;
|
|
|
|
glm::vec3 Skew(1);
|
|
|
|
glm::vec4 Perspective(1);
|
|
|
|
|
|
|
|
glm::decompose(Matrix, Scale, Orientation, Translation, Skew, Perspective);
|
|
|
|
|
2023-02-26 17:33:47 +00:00
|
|
|
glm::mat4 Out = glm::recompose(Scale, Orientation, Translation, Skew, Perspective);
|
|
|
|
|
2024-01-20 09:11:13 +00:00
|
|
|
Error += glm::all(glm::equal(Matrix, Out, glm::epsilon<float>())) ? 0 : 1;
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_scale_translate() {
|
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
glm::vec3 const T(2.0f);
|
|
|
|
glm::vec3 const S(2.0f);
|
|
|
|
|
|
|
|
glm::mat4 Matrix = glm::translate(glm::scale(glm::mat4(1), S), T);
|
|
|
|
|
|
|
|
glm::vec3 Scale(2);
|
|
|
|
glm::quat Orientation;
|
|
|
|
glm::vec3 Translation(2);
|
|
|
|
glm::vec3 Skew(1);
|
|
|
|
glm::vec4 Perspective(1);
|
|
|
|
|
|
|
|
glm::decompose(Matrix, Scale, Orientation, Translation, Skew, Perspective);
|
|
|
|
|
|
|
|
glm::mat4 Out = glm::recompose(Scale, Orientation, Translation, Skew, Perspective);
|
|
|
|
|
|
|
|
Error += glm::all(glm::equal(Matrix, Out, glm::epsilon<float>())) ? 0 : 1;
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
Error += test_identity();
|
|
|
|
Error += test_scale_translate();
|
|
|
|
|
2014-08-31 22:12:38 +00:00
|
|
|
return Error;
|
|
|
|
}
|