mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Merge branch '0.9.2' into 0.9.3
This commit is contained in:
commit
22e51711c1
@ -452,7 +452,7 @@
|
||||
**/
|
||||
|
||||
/*!
|
||||
\defgroup gtx_vector_access GLM_GTX_vector_angle: Vector access
|
||||
\defgroup gtx_vector_access GLM_GTX_vector_access: Vector access
|
||||
\ingroup gtx
|
||||
|
||||
\brief Function to set values to vectors
|
||||
|
@ -149,7 +149,7 @@ namespace quaternion
|
||||
detail::tquat<T> const & x
|
||||
)
|
||||
{
|
||||
return acos(x.w) * T(2);
|
||||
return glm::degrees(acos(x.w) * T(2));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -23,11 +23,12 @@ int test_quat_slerp()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::quat A(0.0f, glm::vec3(0, 0, 1));
|
||||
glm::quat B(90.0f, glm::vec3(0, 0, 1));
|
||||
glm::quat A(glm::vec3(0, 0, 1));
|
||||
glm::quat B(glm::vec3(0, 1, 0));
|
||||
glm::quat C = glm::mix(A, B, 0.5f);
|
||||
|
||||
Error += C == glm::quat(45.f, glm::vec3(0, 0, 1)) ? 0 : 1;
|
||||
glm::quat D(glm::normalize(glm::vec3(0, 1, 1)));
|
||||
|
||||
Error += C == D ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-16
|
||||
// Updated : 2010-09-16
|
||||
// Updated : 2011-05-27
|
||||
// Licence : This source is under MIT licence
|
||||
// File : test/gtc/type_ptr.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -11,8 +11,31 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
bool test_make_pointer()
|
||||
int test_make_pointer_mat()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
int ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
bool ArrayC[] = {true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false};
|
||||
|
||||
glm::mat2x2 Mat2x2A = glm::make_mat2x2(ArrayA);
|
||||
glm::mat2x3 Mat2x3A = glm::make_mat2x3(ArrayA);
|
||||
glm::mat2x4 Mat2x4A = glm::make_mat2x4(ArrayA);
|
||||
glm::mat3x2 Mat3x2A = glm::make_mat3x2(ArrayA);
|
||||
glm::mat3x3 Mat3x3A = glm::make_mat3x3(ArrayA);
|
||||
glm::mat3x4 Mat3x4A = glm::make_mat3x4(ArrayA);
|
||||
glm::mat4x2 Mat4x2A = glm::make_mat4x2(ArrayA);
|
||||
glm::mat4x3 Mat4x3A = glm::make_mat4x3(ArrayA);
|
||||
glm::mat4x4 Mat4x4A = glm::make_mat4x4(ArrayA);
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_make_pointer_vec()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
int ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
bool ArrayC[] = {true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false};
|
||||
@ -29,24 +52,15 @@ bool test_make_pointer()
|
||||
glm::bvec3 Vec3C = glm::make_vec3(ArrayC);
|
||||
glm::bvec4 Vec4C = glm::make_vec4(ArrayC);
|
||||
|
||||
glm::mat2x2 Mat2x2A = glm::make_mat2x2(ArrayA);
|
||||
glm::mat2x3 Mat2x3A = glm::make_mat2x3(ArrayA);
|
||||
glm::mat2x4 Mat2x4A = glm::make_mat2x4(ArrayA);
|
||||
glm::mat3x2 Mat3x2A = glm::make_mat3x2(ArrayA);
|
||||
glm::mat3x3 Mat3x3A = glm::make_mat3x3(ArrayA);
|
||||
glm::mat3x4 Mat3x4A = glm::make_mat3x4(ArrayA);
|
||||
glm::mat4x2 Mat4x2A = glm::make_mat4x2(ArrayA);
|
||||
glm::mat4x3 Mat4x3A = glm::make_mat4x3(ArrayA);
|
||||
glm::mat4x4 Mat4x4A = glm::make_mat4x4(ArrayA);
|
||||
|
||||
return true;
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Failed = 0;
|
||||
int Error = 0;
|
||||
|
||||
Failed += test_make_pointer() ? 0 : 1;
|
||||
Error += test_make_pointer_vec();
|
||||
Error += test_make_pointer_mat();
|
||||
|
||||
return Failed;
|
||||
return Error;
|
||||
}
|
||||
|
@ -11,31 +11,48 @@
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <glm/gtx/epsilon.hpp>
|
||||
|
||||
int test_quat_angleAxis()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1));
|
||||
glm::quat B = glm::angleAxis(90.0f, glm::vec3(0, 0, 1));
|
||||
glm::quat C = glm::mix(A, B, 0.5f);
|
||||
glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
|
||||
|
||||
Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_quat_angle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::quat Q(45.0f, glm::vec3(0, 0, 1));
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += L == 1.0f ? 0 : 1;
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
float A = glm::angle(N);
|
||||
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::quat Q(45.0f, glm::vec3(0, 0, 2));
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(0, 1, 1)));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += L == 1.0f ? 0 : 1;
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
float A = glm::angle(N);
|
||||
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::quat Q(45.0f, glm::vec3(1, 2, 3));
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(1, 2, 3)));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += L == 1.0f ? 0 : 1;
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
float A = glm::angle(N);
|
||||
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
}
|
||||
@ -48,6 +65,7 @@ int main()
|
||||
int Error = 0;
|
||||
|
||||
Error += test_quat_angle();
|
||||
Error += test_quat_angleAxis();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user