master
			
			
		
		
						commit
						f4dbbd42ef
					
				
				 25 changed files with 304 additions and 8 deletions
			
			
		@ -0,0 +1,107 @@ | 
				
			||||
///////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
 | 
				
			||||
///////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||
// Created : 2011-05-25
 | 
				
			||||
// Updated : 2011-05-25
 | 
				
			||||
// Licence : This source is under MIT License
 | 
				
			||||
// File    : test/core/type_length.cpp
 | 
				
			||||
///////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||
 | 
				
			||||
#include <glm/glm.hpp> | 
				
			||||
#include <glm/gtc/half_float.hpp> | 
				
			||||
 | 
				
			||||
int test_length_mat_non_squared() | 
				
			||||
{ | 
				
			||||
	int Error = 0; | 
				
			||||
 | 
				
			||||
	Error += glm::mat2x3().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::mat2x4().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::mat3x2().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::mat3x4().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::mat4x2().length() == 4 ? 0 : 1; | 
				
			||||
	Error += glm::mat4x3().length() == 4 ? 0 : 1; | 
				
			||||
	
 | 
				
			||||
	Error += glm::dmat2x3().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::dmat2x4().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::dmat3x2().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::dmat3x4().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::dmat4x2().length() == 4 ? 0 : 1; | 
				
			||||
	Error += glm::dmat4x3().length() == 4 ? 0 : 1; | 
				
			||||
	
 | 
				
			||||
	Error += glm::hmat2x3().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::hmat2x4().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::hmat3x2().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::hmat3x4().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::hmat4x2().length() == 4 ? 0 : 1; | 
				
			||||
	Error += glm::hmat4x3().length() == 4 ? 0 : 1; | 
				
			||||
	
 | 
				
			||||
	return Error; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
int test_length_mat() | 
				
			||||
{ | 
				
			||||
	int Error = 0; | 
				
			||||
	
 | 
				
			||||
	Error += glm::mat2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::mat3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::mat4().length() == 4 ? 0 : 1; | 
				
			||||
	Error += glm::mat2x2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::mat3x3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::mat4x4().length() == 4 ? 0 : 1; | 
				
			||||
	
 | 
				
			||||
	Error += glm::dmat2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::dmat3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::dmat4().length() == 4 ? 0 : 1; | 
				
			||||
	Error += glm::dmat2x2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::dmat3x3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::dmat4x4().length() == 4 ? 0 : 1; | 
				
			||||
	
 | 
				
			||||
	Error += glm::hmat2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::hmat3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::hmat4().length() == 4 ? 0 : 1; | 
				
			||||
	Error += glm::hmat2x2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::hmat3x3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::hmat4x4().length() == 4 ? 0 : 1; | 
				
			||||
	
 | 
				
			||||
	return Error; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
int test_length_vec() | 
				
			||||
{ | 
				
			||||
 | 
				
			||||
	int Error = 0; | 
				
			||||
	
 | 
				
			||||
	Error += glm::vec2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::vec3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::vec4().length() == 4 ? 0 : 1; | 
				
			||||
 | 
				
			||||
	Error += glm::ivec2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::ivec3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::ivec4().length() == 4 ? 0 : 1; | 
				
			||||
 | 
				
			||||
	Error += glm::uvec2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::uvec3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::uvec4().length() == 4 ? 0 : 1; | 
				
			||||
 | 
				
			||||
	Error += glm::hvec2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::hvec3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::hvec4().length() == 4 ? 0 : 1; | 
				
			||||
	
 | 
				
			||||
	Error += glm::dvec2().length() == 2 ? 0 : 1; | 
				
			||||
	Error += glm::dvec3().length() == 3 ? 0 : 1; | 
				
			||||
	Error += glm::dvec4().length() == 4 ? 0 : 1; | 
				
			||||
	
 | 
				
			||||
	return Error; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
int main() | 
				
			||||
{ | 
				
			||||
	int Error = 0; | 
				
			||||
	
 | 
				
			||||
	Error += test_length_vec(); | 
				
			||||
	Error += test_length_mat(); | 
				
			||||
	Error += test_length_mat_non_squared(); | 
				
			||||
	
 | 
				
			||||
	return Error; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
@ -0,0 +1,53 @@ | 
				
			||||
///////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
 | 
				
			||||
///////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||
// Created : 2011-05-25
 | 
				
			||||
// Updated : 2011-05-25
 | 
				
			||||
// Licence : This source is under MIT licence
 | 
				
			||||
// File    : test/gtx/quaternion.cpp
 | 
				
			||||
///////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||
 | 
				
			||||
#include <glm/glm.hpp> | 
				
			||||
#include <glm/gtx/quaternion.hpp> | 
				
			||||
#include <glm/gtx/epsilon.hpp> | 
				
			||||
 | 
				
			||||
int test_quat_angle() | 
				
			||||
{ | 
				
			||||
    int Error = 0; | 
				
			||||
    
 | 
				
			||||
    { | 
				
			||||
        glm::quat Q(45.0f, glm::vec3(0, 0, 1)); | 
				
			||||
        glm::quat N = glm::normalize(Q); | 
				
			||||
        float L = glm::length(N); | 
				
			||||
        Error += L == 1.0f ? 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 N = glm::normalize(Q); | 
				
			||||
        float L = glm::length(N); | 
				
			||||
        Error += L == 1.0f ? 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 N = glm::normalize(Q); | 
				
			||||
        float L = glm::length(N); | 
				
			||||
        Error += L == 1.0f ? 0 : 1; | 
				
			||||
        float A = glm::angle(N); | 
				
			||||
        Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; | 
				
			||||
    } | 
				
			||||
    
 | 
				
			||||
    return Error; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
int main() | 
				
			||||
{ | 
				
			||||
	int Error = 0; | 
				
			||||
    
 | 
				
			||||
    Error += test_quat_angle(); | 
				
			||||
 | 
				
			||||
	return Error; | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in New Issue