Added a GTX_euler_angle unit test

This commit is contained in:
Christophe Riccio 2013-09-18 23:05:50 +02:00
parent 08c95429fe
commit 61589b8a28
4 changed files with 78 additions and 17 deletions

View file

@ -10,6 +10,7 @@
#include <glm/glm.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/quaternion.hpp>
#include <vector>
static int test_scalar_size()
{
@ -854,9 +855,33 @@ static int test_fvec_conversion()
return Error;
}
#include <omp.h>
static int test_openmp()
{
std::vector<glm::u8vec3> VectorA(1000);
std::vector<glm::u8vec3> VectorB(1000);
std::vector<glm::u8vec3> VectorC(1000);
for (std::size_t i = 0; i < VectorA.size(); ++i)
{
VectorA[i] = glm::u8vec3(1, 1, 1);
VectorB[i] = glm::u8vec3(1, 1, 1);
}
#pragma omp parallel for default(none) shared(VectorA, VectorB, VectorC)
for (int i = 0; i < VectorC.size(); ++i)
{
VectorC[i] = VectorA[i] + VectorB[i];
}
return 0;
}
int main()
{
int Error(0);
Error += test_openmp();
Error += test_scalar_size();
Error += test_fvec_size();
Error += test_fvec_precision();

View file

@ -1,4 +1,5 @@
glmCreateTestGTC(gtx_bit)
glmCreateTestGTC(gtx_euler_angle)
glmCreateTestGTC(gtx_gradient_paint)
glmCreateTestGTC(gtx_integer)
glmCreateTestGTC(gtx_matrix_interpolation)

View file

@ -0,0 +1,35 @@
// Code sample from Filippo Ramaciotti
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/string_cast.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <iostream>
using namespace glm;
int main()
{
f32 first = 1.046 ;
f32 second = 0.52 ;
f32 third = -0.785;
fmat4 rotationEuler = eulerAngleYXZ(first, second, third);
fmat4 rotationInvertedY = eulerAngleY(-1.f*first) * eulerAngleX(second) * eulerAngleZ(third);
fmat4 rotationDumb = glm::fmat4();
rotationDumb = rotate(rotationDumb, first, glm::fvec3(0,1,0));
rotationDumb = rotate(rotationDumb, second, glm::fvec3(1,0,0));
rotationDumb = rotate(rotationDumb, third, glm::fvec3(0,0,1));
std::cout << glm::to_string(fmat3(rotationEuler)) << std::endl;
std::cout << glm::to_string(fmat3(rotationDumb)) << std::endl;
std::cout << glm::to_string(fmat3(rotationInvertedY )) << std::endl;
std::cout <<"\nRESIDUAL\n";
std::cout << glm::to_string(fmat3(rotationEuler-(rotationDumb))) << std::endl;
std::cout << glm::to_string(fmat3(rotationEuler-(rotationInvertedY ))) << std::endl;
return 0;
}

View file

@ -12,29 +12,29 @@
int test_rotate()
{
int Error = 0;
glm::vec2 A = glm::rotate(glm::vec2(1, 0), 90.f);
int Error = 0;
glm::vec3 B = glm::rotate(glm::vec3(1, 0, 0), 90.f, glm::vec3(0, 0, 1));
glm::vec2 A = glm::rotate(glm::vec2(1, 0), 90.f);
glm::vec4 C = glm::rotate(glm::vec4(1, 0, 0, 1), 90.f, glm::vec3(0, 0, 1));
glm::vec3 B = glm::rotate(glm::vec3(1, 0, 0), 90.f, glm::vec3(0, 0, 1));
glm::vec3 D = glm::rotateX(glm::vec3(1, 0, 0), 90.f);
glm::vec4 C = glm::rotate(glm::vec4(1, 0, 0, 1), 90.f, glm::vec3(0, 0, 1));
glm::vec4 E = glm::rotateX(glm::vec4(1, 0, 0, 1), 90.f);
glm::vec3 F = glm::rotateY(glm::vec3(1, 0, 0), 90.f);
glm::vec3 D = glm::rotateX(glm::vec3(1, 0, 0), 90.f);
glm::vec4 G = glm::rotateY(glm::vec4(1, 0, 0, 1), 90.f);
glm::vec3 H = glm::rotateZ(glm::vec3(1, 0, 0), 90.f);
glm::vec4 E = glm::rotateX(glm::vec4(1, 0, 0, 1), 90.f);
glm::vec4 I = glm::rotateZ(glm::vec4(1, 0, 0,1 ), 90.f);
glm::mat4 O = glm::orientation(glm::normalize(glm::vec3(1)), glm::vec3(0, 0, 1));
return Error;
glm::vec3 F = glm::rotateY(glm::vec3(1, 0, 0), 90.f);
glm::vec4 G = glm::rotateY(glm::vec4(1, 0, 0, 1), 90.f);
glm::vec3 H = glm::rotateZ(glm::vec3(1, 0, 0), 90.f);
glm::vec4 I = glm::rotateZ(glm::vec4(1, 0, 0,1 ), 90.f);
glm::mat4 O = glm::orientation(glm::normalize(glm::vec3(1)), glm::vec3(0, 0, 1));
return Error;
}
int test_rotateX()