Fixed matrix conversions and added unit tests #371

This commit is contained in:
Christophe Riccio
2015-08-01 21:40:36 +02:00
parent 6ccdafb718
commit d6ae2fd694
14 changed files with 411 additions and 16 deletions

View File

@@ -33,6 +33,14 @@
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
int test_operators()
@@ -120,6 +128,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat2 B(A);
glm::mat2 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error(0);
@@ -129,6 +172,7 @@ int main()
assert(glm::mat2::cols == glm::mat2::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();
Error += test_inverse();

View File

@@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static int test_operators()
@@ -94,6 +102,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat2x3 B(A);
glm::mat2x3 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@@ -103,6 +146,7 @@ int main()
assert(glm::mat2x3::cols == glm::mat2x3::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static int test_operators()
@@ -94,6 +102,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat2x4 B(A);
glm::mat2x4 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@@ -103,6 +146,7 @@ int main()
assert(glm::mat2x4::cols == glm::mat2x4::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static bool test_operators()
@@ -98,6 +106,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat3x2 B(A);
glm::mat3x2 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@@ -107,6 +150,7 @@ int main()
assert(glm::mat3x2::cols == glm::mat3x2::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@@ -32,7 +32,15 @@
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <cstdio>
#include <vector>
@@ -157,6 +165,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat3x3 B(A);
glm::mat3x3 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@@ -166,6 +209,7 @@ int main()
assert(glm::mat3::cols == glm::mat3::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_mat3x3();
Error += test_operators();

View File

@@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static bool test_operators()
@@ -98,6 +106,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat3x4 B(A);
glm::mat3x4 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@@ -107,6 +150,7 @@ int main()
assert(glm::mat3x4::cols == glm::mat3x4::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static int test_operators()
@@ -102,6 +110,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat4x2 B(A);
glm::mat4x2 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@@ -111,6 +154,7 @@ int main()
assert(glm::mat4x2::cols == glm::mat4x2::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static int test_operators()
@@ -102,6 +110,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat4x3 B(A);
glm::mat4x3 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@@ -111,6 +154,7 @@ int main()
assert(glm::mat4x3::cols == glm::mat4x3::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@@ -31,6 +31,14 @@
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <cstdio>
#include <vector>
@@ -274,6 +282,41 @@ int perf_mul()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat4x4 B(A);
glm::mat4x4 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@@ -283,6 +326,7 @@ int main()
assert(glm::mat4::cols == glm::mat4::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_inverse_dmat4x4();
Error += test_inverse_mat4x4();