From 1aaf0525ea29cf37126e65885880dac98fdf128f Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 25 May 2011 09:07:49 +0100 Subject: [PATCH 1/6] Updated quaternion test files --- test/gtc/gtc_quaternion.cpp | 2 +- test/gtx/CMakeLists.txt | 1 + test/gtx/gtx_quaternion.cpp | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/gtx/gtx_quaternion.cpp diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 72bf13a4..7ba8ed88 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2010-09-16 -// Updated : 2010-05-07 +// Updated : 2011-05-25 // Licence : This source is under MIT licence // File : test/gtc/quaternion.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/test/gtx/CMakeLists.txt b/test/gtx/CMakeLists.txt index fca74f16..48258987 100644 --- a/test/gtx/CMakeLists.txt +++ b/test/gtx/CMakeLists.txt @@ -1,5 +1,6 @@ glmCreateTestGTC(gtx_bit) glmCreateTestGTC(gtx_noise) +glmCreateTestGTC(gtx_quaternion) glmCreateTestGTC(gtx_rotate_vector) glmCreateTestGTC(gtx_simd_vec4) glmCreateTestGTC(gtx_simd_mat4) diff --git a/test/gtx/gtx_quaternion.cpp b/test/gtx/gtx_quaternion.cpp new file mode 100644 index 00000000..72bf13a4 --- /dev/null +++ b/test/gtx/gtx_quaternion.cpp @@ -0,0 +1,18 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2010-09-16 +// Updated : 2010-05-07 +// Licence : This source is under MIT licence +// File : test/gtc/quaternion.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +int main() +{ + int Error = 0; + + return Error; +} From f7d6ffc83329b5f45847c6e32553e5c14d4c5369 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 25 May 2011 09:50:01 +0100 Subject: [PATCH 2/6] Added quaternion tests --- glm/gtc/quaternion.hpp | 4 +-- test/gtc/gtc_quaternion.cpp | 71 +++++++++++++++++++++++++++++++++++++ test/gtx/gtx_quaternion.cpp | 43 +++++++++++++++++++--- 3 files changed, 112 insertions(+), 6 deletions(-) diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index a859eede..f6238ccd 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -122,13 +122,13 @@ namespace quaternion ///< GLM_GTC_quaternion extension: Quaternion types and fun /// \addtogroup gtc_quaternion ///@{ - //! Returns the length of the quaternion x. + //! Returns the length of the quaternion. //! From GLM_GTC_quaternion extension. template typename detail::tquat::value_type length( detail::tquat const & q); - //! Returns the normalized quaternion of from x. + //! Returns the normalized quaternion. //! From GLM_GTC_quaternion extension. template detail::tquat normalize( diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 7ba8ed88..f93d167b 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -9,10 +9,81 @@ #include #include +#include + +int test_quat_type() +{ + glm::quat A; + glm::dquat B; + + return 0; +} + +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 C = glm::mix(A, B, 0.5f); + + Error += C != glm::quat(45.f, glm::vec3(0, 0, 1)) ? 0 : 1; + + return Error; +} + +int test_quat_length() +{ + int Error = 0; + + float A = glm::length(glm::quat(45.0f, glm::vec3(0, 0, 1))); + Error += A == 1.0f ? 0 : 1; + float B = glm::length(glm::quat(90.0f, glm::vec3(0, 0, 2))); + Error += B == 2.0f ? 0 : 1; + + return Error; +} + +int test_quat_normalize() +{ + 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_type(); + Error += test_quat_slerp(); + Error += test_quat_length(); + Error += test_quat_normalize(); return Error; } diff --git a/test/gtx/gtx_quaternion.cpp b/test/gtx/gtx_quaternion.cpp index 72bf13a4..241f572c 100644 --- a/test/gtx/gtx_quaternion.cpp +++ b/test/gtx/gtx_quaternion.cpp @@ -1,18 +1,53 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2010-09-16 -// Updated : 2010-05-07 +// Created : 2011-05-25 +// Updated : 2011-05-25 // Licence : This source is under MIT licence -// File : test/gtc/quaternion.cpp +// File : test/gtx/quaternion.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include -#include +#include +#include + +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; } From 740c28a22c4a1eeb3df20b7de865b9bcb446b847 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 25 May 2011 09:58:59 +0100 Subject: [PATCH 3/6] Typo --- test/gtc/gtc_quaternion.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index f93d167b..689cfe27 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -28,19 +28,19 @@ int test_quat_slerp() glm::quat C = glm::mix(A, B, 0.5f); Error += C != glm::quat(45.f, glm::vec3(0, 0, 1)) ? 0 : 1; - + return Error; } int test_quat_length() { int Error = 0; - + float A = glm::length(glm::quat(45.0f, glm::vec3(0, 0, 1))); Error += A == 1.0f ? 0 : 1; float B = glm::length(glm::quat(90.0f, glm::vec3(0, 0, 2))); Error += B == 2.0f ? 0 : 1; - + return Error; } @@ -53,26 +53,20 @@ int test_quat_normalize() 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; } From 2baf928bd50383d2fd8104ffe22c578e906d5ab6 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 25 May 2011 10:00:13 +0100 Subject: [PATCH 4/6] Fixed type cast --- glm/gtc/quaternion.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 742fbde3..27a5c541 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -416,7 +416,7 @@ namespace quaternion{ ) { T angle = acos(dot(x, y)); - return (sin((1 - a) * angle) * x + sin(a * angle) * y) / sin(angle); + return (sin((T(1) - a) * angle) * x + sin(a * angle) * y) / sin(angle); } template From f58cc0900f582fe5f3f39de3d8d0db3016b44297 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 25 May 2011 19:59:31 +0100 Subject: [PATCH 5/6] Added length function tests --- test/core/CMakeLists.txt | 1 + test/core/core_type_length.cpp | 62 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/core/core_type_length.cpp diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index d851ac7d..9b3c64e3 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -1,6 +1,7 @@ glmCreateTestGTC(core_type_float) glmCreateTestGTC(core_type_half) glmCreateTestGTC(core_type_int) +glmCreateTestGTC(core_type_length) glmCreateTestGTC(core_type_mat2x2) glmCreateTestGTC(core_type_mat2x3) glmCreateTestGTC(core_type_mat2x4) diff --git a/test/core/core_type_length.cpp b/test/core/core_type_length.cpp new file mode 100644 index 00000000..7f5dadb9 --- /dev/null +++ b/test/core/core_type_length.cpp @@ -0,0 +1,62 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// 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 + +int test_length_mat_non_squared() +{ + int Error = 0; + + Error += glm::mat2x3().length() == 6 ? 0 : 1; + Error += glm::mat2x4().length() == 8 ? 0 : 1; + Error += glm::mat3x2().length() == 6 ? 0 : 1; + Error += glm::mat3x4().length() == 12 ? 0 : 1; + Error += glm::mat4x2().length() == 8 ? 0 : 1; + Error += glm::mat4x3().length() == 12 ? 0 : 1; + + return Error; +} + +int test_length_mat() +{ + int Error = 0; + + Error += glm::mat2().length() == 4 ? 0 : 1; + Error += glm::mat3().length() == 9 ? 0 : 1; + Error += glm::mat4().length() == 16 ? 0 : 1; + Error += glm::mat2x2().length() == 4 ? 0 : 1; + Error += glm::mat3x3().length() == 9 ? 0 : 1; + Error += glm::mat4x4().length() == 16 ? 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; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_length_vec(); + Error += test_length_mat(); + Error += test_length_mat_non_squared(); + + return Error; +} + From 706c29963682b96160b03f9f264f25650a564d9a Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 26 May 2011 02:23:51 +0100 Subject: [PATCH 6/6] Added length functions to matrix types and quaternions and tests. Ticket #97 --- glm/core/type_mat2x2.hpp | 1 + glm/core/type_mat2x2.inl | 6 +++ glm/core/type_mat2x3.hpp | 1 + glm/core/type_mat2x3.inl | 6 +++ glm/core/type_mat2x4.hpp | 1 + glm/core/type_mat2x4.inl | 6 +++ glm/core/type_mat3x2.hpp | 1 + glm/core/type_mat3x2.inl | 6 +++ glm/core/type_mat3x3.hpp | 1 + glm/core/type_mat3x3.inl | 6 +++ glm/core/type_mat3x4.hpp | 1 + glm/core/type_mat3x4.inl | 6 +++ glm/core/type_mat4x2.hpp | 1 + glm/core/type_mat4x2.inl | 8 +++- glm/core/type_mat4x3.hpp | 1 + glm/core/type_mat4x3.inl | 8 +++- glm/core/type_mat4x4.hpp | 1 + glm/core/type_mat4x4.inl | 8 +++- glm/gtc/quaternion.hpp | 8 +++- test/core/core_type_length.cpp | 69 ++++++++++++++++++++++++++++------ 20 files changed, 130 insertions(+), 16 deletions(-) diff --git a/glm/core/type_mat2x2.hpp b/glm/core/type_mat2x2.hpp index aade1ef4..d3543245 100644 --- a/glm/core/type_mat2x2.hpp +++ b/glm/core/type_mat2x2.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec2 col_type; typedef tvec2 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index 7a53a969..12d04840 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat2x2::size_type tmat2x2::length() const + { + return 2; + } + template GLM_FUNC_QUALIFIER typename tmat2x2::size_type tmat2x2::col_size() { diff --git a/glm/core/type_mat2x3.hpp b/glm/core/type_mat2x3.hpp index ed87f9e2..45169a8e 100644 --- a/glm/core/type_mat2x3.hpp +++ b/glm/core/type_mat2x3.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec3 col_type; typedef tvec2 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat2x3.inl b/glm/core/type_mat2x3.inl index 83e8b2e3..77441fb0 100644 --- a/glm/core/type_mat2x3.inl +++ b/glm/core/type_mat2x3.inl @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat2x3::size_type tmat2x3::length() const + { + return 2; + } + template GLM_FUNC_QUALIFIER typename tmat2x3::size_type tmat2x3::col_size() { diff --git a/glm/core/type_mat2x4.hpp b/glm/core/type_mat2x4.hpp index a14cc033..229b9996 100644 --- a/glm/core/type_mat2x4.hpp +++ b/glm/core/type_mat2x4.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec4 col_type; typedef tvec2 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat2x4.inl b/glm/core/type_mat2x4.inl index b19193f6..4736805d 100644 --- a/glm/core/type_mat2x4.inl +++ b/glm/core/type_mat2x4.inl @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat2x4::size_type tmat2x4::length() const + { + return 2; + } + template GLM_FUNC_QUALIFIER typename tmat2x4::size_type tmat2x4::col_size() { diff --git a/glm/core/type_mat3x2.hpp b/glm/core/type_mat3x2.hpp index 3457b72f..2c61e5c7 100644 --- a/glm/core/type_mat3x2.hpp +++ b/glm/core/type_mat3x2.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec2 col_type; typedef tvec3 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat3x2.inl b/glm/core/type_mat3x2.inl index 5fddb4c1..ec95a3dc 100644 --- a/glm/core/type_mat3x2.inl +++ b/glm/core/type_mat3x2.inl @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat3x2::size_type tmat3x2::length() const + { + return 2; + } + template GLM_FUNC_QUALIFIER typename tmat3x2::size_type tmat3x2::col_size() { diff --git a/glm/core/type_mat3x3.hpp b/glm/core/type_mat3x3.hpp index bf18c167..7d534a93 100644 --- a/glm/core/type_mat3x3.hpp +++ b/glm/core/type_mat3x3.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec3 col_type; typedef tvec3 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat3x3.inl b/glm/core/type_mat3x3.inl index 667f2235..80a3e8ed 100644 --- a/glm/core/type_mat3x3.inl +++ b/glm/core/type_mat3x3.inl @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat3x3::size_type tmat3x3::length() const + { + return 3; + } + template GLM_FUNC_QUALIFIER typename tmat3x3::size_type tmat3x3::col_size() { diff --git a/glm/core/type_mat3x4.hpp b/glm/core/type_mat3x4.hpp index 1f84ec7b..fa96870f 100644 --- a/glm/core/type_mat3x4.hpp +++ b/glm/core/type_mat3x4.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec4 col_type; typedef tvec3 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat3x4.inl b/glm/core/type_mat3x4.inl index 3d322718..e840fc19 100644 --- a/glm/core/type_mat3x4.inl +++ b/glm/core/type_mat3x4.inl @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat3x4::size_type tmat3x4::length() const + { + return 3; + } + template GLM_FUNC_QUALIFIER typename tmat3x4::size_type tmat3x4::col_size() { diff --git a/glm/core/type_mat4x2.hpp b/glm/core/type_mat4x2.hpp index 3354ce8e..7959423f 100644 --- a/glm/core/type_mat4x2.hpp +++ b/glm/core/type_mat4x2.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec2 col_type; typedef tvec4 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat4x2.inl b/glm/core/type_mat4x2.inl index cb30a98c..7121d1b9 100644 --- a/glm/core/type_mat4x2.inl +++ b/glm/core/type_mat4x2.inl @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2006-10-01 -// Updated : 2010-02-03 +// Updated : 2011-05-26 // Licence : This source is under MIT License // File : glm/core/type_mat4x2.inl /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat4x2::size_type tmat4x2::length() const + { + return 4; + } + template GLM_FUNC_QUALIFIER typename tmat4x2::size_type tmat4x2::col_size() { diff --git a/glm/core/type_mat4x3.hpp b/glm/core/type_mat4x3.hpp index b15a3c30..226b0dc2 100644 --- a/glm/core/type_mat4x3.hpp +++ b/glm/core/type_mat4x3.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec3 col_type; typedef tvec4 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat4x3.inl b/glm/core/type_mat4x3.inl index b882af27..af199e70 100644 --- a/glm/core/type_mat4x3.inl +++ b/glm/core/type_mat4x3.inl @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2006-04-17 -// Updated : 2010-02-02 +// Updated : 2011-05-26 // Licence : This source is under MIT License // File : glm/core/type_mat4x3.inl /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat4x3::size_type tmat4x3::length() const + { + return 4; + } + template GLM_FUNC_QUALIFIER typename tmat4x3::size_type tmat4x3::col_size() { diff --git a/glm/core/type_mat4x4.hpp b/glm/core/type_mat4x4.hpp index 6aa1f68a..4e510fd1 100644 --- a/glm/core/type_mat4x4.hpp +++ b/glm/core/type_mat4x4.hpp @@ -45,6 +45,7 @@ namespace glm typedef std::size_t size_type; typedef tvec4 col_type; typedef tvec4 row_type; + GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type row_size(); diff --git a/glm/core/type_mat4x4.inl b/glm/core/type_mat4x4.inl index 8df4b062..593ff283 100644 --- a/glm/core/type_mat4x4.inl +++ b/glm/core/type_mat4x4.inl @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2005-01-27 -// Updated : 2010-02-05 +// Updated : 2011-05-26 // Licence : This source is under MIT License // File : glm/core/type_mat4x4.inl /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -10,6 +10,12 @@ namespace glm{ namespace detail { + template + GLM_FUNC_QUALIFIER typename tmat4x4::size_type tmat4x4::length() const + { + return 4; + } + template GLM_FUNC_QUALIFIER typename tmat4x4::size_type tmat4x4::col_size() { diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index d5d087a8..923b810c 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -35,10 +35,16 @@ namespace detail template struct tquat// : public genType { - typedef T value_type; + + enum ctor{null}; + + typedef T value_type; + typedef std::size_t size_type; public: value_type x, y, z, w; + + GLM_FUNC_DECL size_type length() const; // Constructors tquat(); diff --git a/test/core/core_type_length.cpp b/test/core/core_type_length.cpp index 7f5dadb9..7b496173 100644 --- a/test/core/core_type_length.cpp +++ b/test/core/core_type_length.cpp @@ -8,17 +8,32 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include +#include 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::mat2x3().length() == 6 ? 0 : 1; - Error += glm::mat2x4().length() == 8 ? 0 : 1; - Error += glm::mat3x2().length() == 6 ? 0 : 1; - Error += glm::mat3x4().length() == 12 ? 0 : 1; - Error += glm::mat4x2().length() == 8 ? 0 : 1; - Error += glm::mat4x3().length() == 12 ? 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; } @@ -27,12 +42,26 @@ int test_length_mat() { int Error = 0; - Error += glm::mat2().length() == 4 ? 0 : 1; - Error += glm::mat3().length() == 9 ? 0 : 1; - Error += glm::mat4().length() == 16 ? 0 : 1; - Error += glm::mat2x2().length() == 4 ? 0 : 1; - Error += glm::mat3x3().length() == 9 ? 0 : 1; - Error += glm::mat4x4().length() == 16 ? 0 : 1; + 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; } @@ -45,6 +74,22 @@ int test_length_vec() 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; }