glm/test/gtc/gtc_matrix_inverse.cpp

52 lines
1.0 KiB
C++
Raw Normal View History

2011-05-08 00:08:16 +00:00
#include <glm/gtc/matrix_inverse.hpp>
2015-09-30 23:30:13 +00:00
#include <glm/gtc/epsilon.hpp>
static int test_affine()
2015-09-30 23:30:13 +00:00
{
int Error = 0;
{
glm::mat3 const M(
2.f, 0.f, 0.f,
0.f, 2.f, 0.f,
0.f, 0.f, 1.f);
glm::mat3 const A = glm::affineInverse(M);
glm::mat3 const I = glm::inverse(M);
glm::mat3 const R = glm::affineInverse(A);
2015-10-01 21:25:21 +00:00
for(glm::length_t i = 0; i < A.length(); ++i)
{
Error += glm::all(glm::epsilonEqual(M[i], R[i], 0.01f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(A[i], I[i], 0.01f)) ? 0 : 1;
}
2015-09-30 23:30:13 +00:00
}
{
glm::mat4 const M(
2.f, 0.f, 0.f, 0.f,
0.f, 2.f, 0.f, 0.f,
0.f, 0.f, 2.f, 0.f,
0.f, 0.f, 0.f, 1.f);
glm::mat4 const A = glm::affineInverse(M);
glm::mat4 const I = glm::inverse(M);
glm::mat4 const R = glm::affineInverse(A);
2015-10-01 21:25:21 +00:00
for(glm::length_t i = 0; i < A.length(); ++i)
{
Error += glm::all(glm::epsilonEqual(M[i], R[i], 0.01f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(A[i], I[i], 0.01f)) ? 0 : 1;
}
2015-09-30 23:30:13 +00:00
}
return Error;
}
2011-01-20 11:02:39 +00:00
2011-01-24 15:44:14 +00:00
int main()
2011-01-20 11:02:39 +00:00
{
2012-04-07 16:18:04 +00:00
int Error = 0;
2011-01-20 11:02:39 +00:00
2015-09-30 23:30:13 +00:00
Error += test_affine();
2012-04-07 16:18:04 +00:00
return Error;
2011-01-20 11:02:39 +00:00
}