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

@@ -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()