Browse Source

Merge branch '0.9.1' of ssh://g-truc.git.sourceforge.net/gitroot/ogl-math/ogl-math into 0.9.1

Christophe Riccio 14 years ago
parent
commit
8f0ecea1a2
4 changed files with 41 additions and 108 deletions
  1. 1 1
      glm/gtc/quaternion.inl
  2. 3 3
      glm/gtx/quaternion.hpp
  3. 0 1
      glm/gtx/quaternion.inl
  4. 37 103
      test/core/core_func_matrix.cpp

+ 1 - 1
glm/gtc/quaternion.inl

@@ -422,7 +422,7 @@ namespace quaternion{
 		detail::tquat<T> const & q
 	)
     {
-        return gtc::quaternion::conjugate(q) / gtc::quaternion::length(q);
+        return gtc::quaternion::conjugate(q) / gtc::quaternion::dot(q, q);
     }
 
     template <typename T> 

+ 3 - 3
glm/gtx/quaternion.hpp

@@ -121,7 +121,7 @@ namespace glm
 		detail::tvec3<valType> axis(
 			detail::tquat<valType> const & x);
 
-		//! Build a quaternion from an angle and an axis. 
+		//! Build a quaternion from an angle and a normalized axis. 
 		//! From GLM_GTX_quaternion extension.
 		template <typename valType> 
 		detail::tquat<valType> angleAxis(
@@ -130,12 +130,12 @@ namespace glm
 			valType const & y, 
 			valType const & z);
 
-        //! Build a quaternion from an angle and an axis.
+        //! Build a quaternion from an angle and a normalized axis.
 		//! From GLM_GTX_quaternion extension.
 		template <typename valType> 
 		detail::tquat<valType> angleAxis(
 			valType const & angle, 
-			detail::tvec3<valType> const & v);
+			detail::tvec3<valType> const & axis);
 
 		//! Extract the real component of a quaternion.
 		//! From GLM_GTX_quaternion extension.

+ 0 - 1
glm/gtx/quaternion.inl

@@ -185,7 +185,6 @@ namespace quaternion
 	)
     {
         detail::tquat<valType> result;
-        detail::tvec3<valType> v_normalized = glm::normalize(v);
 
 		valType a = glm::radians(angle);
         valType s = glm::sin(a * valType(0.5));

+ 37 - 103
test/core/core_func_matrix.cpp

@@ -4,145 +4,79 @@
 // Created : 2011-01-15
 // Updated : 2011-01-15
 // Licence : This source is under MIT licence
-// File    : test/gtx/simd-mat4.cpp
+// File    : test/core/func_matrix.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2
 #include <glm/glm.hpp>
 
-int test_static_assert()
+int test_matrixCompMult()
 {
-	//glm::lessThan(glm::mat4(0), glm::mat4(4));
 
-	return 0;
-}
-
-int test_lessThan_vec2()
-{
-	glm::bvec2 O = glm::bvec2(true, false);
-
-	glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2));
-	assert(glm::all(glm::equal(O, A)));
-
-	glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2));
-	assert(glm::all(glm::equal(O, B)));
-
-	glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2));
-	assert(glm::all(glm::equal(O, C)));
-
-	return 0;
-}
-
-int test_lessThan_vec3()
-{
-	glm::bvec3 O = glm::bvec3(true, true, false);
-
-	glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2));
-	assert(glm::all(glm::equal(O, A)));
-
-	glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2));
-	assert(glm::all(glm::equal(O, B)));
-
-	glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2));
-	assert(glm::all(glm::equal(O, C)));
-
-	return 0;
-}
-
-int test_lessThan_vec4()
-{
-	glm::bvec4 O = glm::bvec4(true, true, false, false);
-
-	glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3));
-	assert(glm::all(glm::equal(O, A)));
-
-	glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3));
-	assert(glm::all(glm::equal(O, B)));
-
-	glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3));
-	assert(glm::all(glm::equal(O, C)));
 
 	return 0;
 }
 
-int test_greaterThanEqual_vec2()
+int test_outerProduct()
 {
-	glm::bvec2 O = glm::bvec2(false, true);
-
-	glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2));
-	assert(glm::all(glm::equal(O, A)));
 
-	glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2));
-	assert(glm::all(glm::equal(O, B)));
-
-	glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2));
-	assert(glm::all(glm::equal(O, C)));
 
 	return 0;
 }
 
-int test_greaterThanEqual_vec3()
+int test_transpose()
 {
-	glm::bvec3 O = glm::bvec3(false, false, true);
-
-	glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2));
-	assert(glm::all(glm::equal(O, A)));
 
-	glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2));
-	assert(glm::all(glm::equal(O, B)));
-
-	glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2));
-	assert(glm::all(glm::equal(O, C)));
 
 	return 0;
 }
 
-int test_greaterThanEqual_vec4()
+int test_determinant()
 {
-	glm::bvec4 O = glm::bvec4(false, false, true, true);
-
-	glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3));
-	assert(glm::all(glm::equal(O, A)));
 
-	glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3));
-	assert(glm::all(glm::equal(O, B)));
-
-	glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3));
-	assert(glm::all(glm::equal(O, C)));
 
 	return 0;
 }
 
-int test_all()
+int test_inverse()
 {
-	assert(glm::all(glm::bvec2(true, true)));
-	assert(!glm::all(glm::bvec2(true, false)));
-	assert(!glm::all(glm::bvec2(false, false)));
-
-	assert(glm::all(glm::bvec3(true, true, true)));
-	assert(!glm::all(glm::bvec3(true, false, true)));
-	assert(!glm::all(glm::bvec3(false, false, false)));
+	int Failed(0);
+
+	glm::mat4x4 A4x4(
+		glm::vec4(1, 0, 1, 0), 
+		glm::vec4(0, 1, 0, 0), 
+		glm::vec4(0, 0, 1, 0), 
+		glm::vec4(0, 0, 0, 1));
+	glm::mat4x4 B4x4 = glm::inverse(A4x4);
+	glm::mat4x4 I4x4 = A4x4 * B4x4;
+	Failed += I4x4 == glm::mat4x4(1) ? 0 : 1;
+
+	glm::mat3x3 A3x3(
+		glm::vec3(1, 0, 1), 
+		glm::vec3(0, 1, 0), 
+		glm::vec3(0, 0, 1));
+	glm::mat3x3 B3x3 = glm::inverse(A3x3);
+	glm::mat3x3 I3x3 = A3x3 * B3x3;
+	Failed += I3x3 == glm::mat3x3(1) ? 0 : 1;
+
+	glm::mat2x2 A2x2(
+		glm::vec2(1, 1), 
+		glm::vec2(0, 1));
+	glm::mat2x2 B2x2 = glm::inverse(A2x2);
+	glm::mat2x2 I2x2 = A2x2 * B2x2;
+	Failed += I2x2 == glm::mat2x2(1) ? 0 : 1;
 
-	assert(glm::all(glm::bvec4(true, true, true, true)));
-	assert(!glm::all(glm::bvec4(true, false, true, false)));
-	assert(!glm::all(glm::bvec4(false, false, false, false)));
-
-	return 0;
+	return Failed;
 }
 
 
 int main()
 {
 	int Failed = 0;
-	Failed += test_static_assert();
-	Failed += test_lessThan_vec2();
-	Failed += test_lessThan_vec3();
-	Failed += test_lessThan_vec4();
-	Failed += test_greaterThanEqual_vec2();
-	Failed += test_greaterThanEqual_vec3();
-	Failed += test_greaterThanEqual_vec4();
-	Failed += test_all();
-
+	Failed += test_matrixCompMult();
+	Failed += test_outerProduct();
+	Failed += test_transpose();
+	Failed += test_determinant();
+	Failed += test_inverse();
 	return Failed;
 }