Added a GTX_euler_angle unit test
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/type_precision.hpp>
|
#include <glm/gtc/type_precision.hpp>
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
static int test_scalar_size()
|
static int test_scalar_size()
|
||||||
{
|
{
|
||||||
@@ -854,9 +855,33 @@ static int test_fvec_conversion()
|
|||||||
return Error;
|
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 main()
|
||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
|
Error += test_openmp();
|
||||||
Error += test_scalar_size();
|
Error += test_scalar_size();
|
||||||
Error += test_fvec_size();
|
Error += test_fvec_size();
|
||||||
Error += test_fvec_precision();
|
Error += test_fvec_precision();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
glmCreateTestGTC(gtx_bit)
|
glmCreateTestGTC(gtx_bit)
|
||||||
|
glmCreateTestGTC(gtx_euler_angle)
|
||||||
glmCreateTestGTC(gtx_gradient_paint)
|
glmCreateTestGTC(gtx_gradient_paint)
|
||||||
glmCreateTestGTC(gtx_integer)
|
glmCreateTestGTC(gtx_integer)
|
||||||
glmCreateTestGTC(gtx_matrix_interpolation)
|
glmCreateTestGTC(gtx_matrix_interpolation)
|
||||||
|
|||||||
35
test/gtx/gtx_euler_angle.cpp
Normal file
35
test/gtx/gtx_euler_angle.cpp
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user