Added length functions to matrix types and quaternions and tests. Ticket #97

master
Christophe Riccio ago%!(EXTRA string=14 years)
parent 9e1bc811e3
commit 706c299636
  1. 1
      glm/core/type_mat2x2.hpp
  2. 6
      glm/core/type_mat2x2.inl
  3. 1
      glm/core/type_mat2x3.hpp
  4. 6
      glm/core/type_mat2x3.inl
  5. 1
      glm/core/type_mat2x4.hpp
  6. 6
      glm/core/type_mat2x4.inl
  7. 1
      glm/core/type_mat3x2.hpp
  8. 6
      glm/core/type_mat3x2.inl
  9. 1
      glm/core/type_mat3x3.hpp
  10. 6
      glm/core/type_mat3x3.inl
  11. 1
      glm/core/type_mat3x4.hpp
  12. 6
      glm/core/type_mat3x4.inl
  13. 1
      glm/core/type_mat4x2.hpp
  14. 8
      glm/core/type_mat4x2.inl
  15. 1
      glm/core/type_mat4x3.hpp
  16. 8
      glm/core/type_mat4x3.inl
  17. 1
      glm/core/type_mat4x4.hpp
  18. 8
      glm/core/type_mat4x4.inl
  19. 8
      glm/gtc/quaternion.hpp
  20. 69
      test/core/core_type_length.cpp

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec2<T> col_type; typedef tvec2<T> col_type;
typedef tvec2<T> row_type; typedef tvec2<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x2<T>::size_type tmat2x2<T>::length() const
{
return 2;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x2<T>::size_type tmat2x2<T>::col_size() GLM_FUNC_QUALIFIER typename tmat2x2<T>::size_type tmat2x2<T>::col_size()
{ {

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec3<T> col_type; typedef tvec3<T> col_type;
typedef tvec2<T> row_type; typedef tvec2<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x3<T>::size_type tmat2x3<T>::length() const
{
return 2;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x3<T>::size_type tmat2x3<T>::col_size() GLM_FUNC_QUALIFIER typename tmat2x3<T>::size_type tmat2x3<T>::col_size()
{ {

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec4<T> col_type; typedef tvec4<T> col_type;
typedef tvec2<T> row_type; typedef tvec2<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x4<T>::size_type tmat2x4<T>::length() const
{
return 2;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x4<T>::size_type tmat2x4<T>::col_size() GLM_FUNC_QUALIFIER typename tmat2x4<T>::size_type tmat2x4<T>::col_size()
{ {

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec2<T> col_type; typedef tvec2<T> col_type;
typedef tvec3<T> row_type; typedef tvec3<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x2<T>::size_type tmat3x2<T>::length() const
{
return 2;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x2<T>::size_type tmat3x2<T>::col_size() GLM_FUNC_QUALIFIER typename tmat3x2<T>::size_type tmat3x2<T>::col_size()
{ {

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec3<T> col_type; typedef tvec3<T> col_type;
typedef tvec3<T> row_type; typedef tvec3<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x3<T>::size_type tmat3x3<T>::length() const
{
return 3;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x3<T>::size_type tmat3x3<T>::col_size() GLM_FUNC_QUALIFIER typename tmat3x3<T>::size_type tmat3x3<T>::col_size()
{ {

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec4<T> col_type; typedef tvec4<T> col_type;
typedef tvec3<T> row_type; typedef tvec3<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x4<T>::size_type tmat3x4<T>::length() const
{
return 3;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x4<T>::size_type tmat3x4<T>::col_size() GLM_FUNC_QUALIFIER typename tmat3x4<T>::size_type tmat3x4<T>::col_size()
{ {

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec2<T> col_type; typedef tvec2<T> col_type;
typedef tvec4<T> row_type; typedef tvec4<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -2,7 +2,7 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2006-10-01 // Created : 2006-10-01
// Updated : 2010-02-03 // Updated : 2011-05-26
// Licence : This source is under MIT License // Licence : This source is under MIT License
// File : glm/core/type_mat4x2.inl // File : glm/core/type_mat4x2.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x2<T>::size_type tmat4x2<T>::length() const
{
return 4;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x2<T>::size_type tmat4x2<T>::col_size() GLM_FUNC_QUALIFIER typename tmat4x2<T>::size_type tmat4x2<T>::col_size()
{ {

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec3<T> col_type; typedef tvec3<T> col_type;
typedef tvec4<T> row_type; typedef tvec4<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -2,7 +2,7 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2006-04-17 // Created : 2006-04-17
// Updated : 2010-02-02 // Updated : 2011-05-26
// Licence : This source is under MIT License // Licence : This source is under MIT License
// File : glm/core/type_mat4x3.inl // File : glm/core/type_mat4x3.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x3<T>::size_type tmat4x3<T>::length() const
{
return 4;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x3<T>::size_type tmat4x3<T>::col_size() GLM_FUNC_QUALIFIER typename tmat4x3<T>::size_type tmat4x3<T>::col_size()
{ {

@ -45,6 +45,7 @@ namespace glm
typedef std::size_t size_type; typedef std::size_t size_type;
typedef tvec4<T> col_type; typedef tvec4<T> col_type;
typedef tvec4<T> row_type; typedef tvec4<T> row_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size(); static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size(); static GLM_FUNC_DECL size_type row_size();

@ -2,7 +2,7 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2005-01-27 // Created : 2005-01-27
// Updated : 2010-02-05 // Updated : 2011-05-26
// Licence : This source is under MIT License // Licence : This source is under MIT License
// File : glm/core/type_mat4x4.inl // File : glm/core/type_mat4x4.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -10,6 +10,12 @@
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x4<T>::size_type tmat4x4<T>::length() const
{
return 4;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x4<T>::size_type tmat4x4<T>::col_size() GLM_FUNC_QUALIFIER typename tmat4x4<T>::size_type tmat4x4<T>::col_size()
{ {

@ -35,11 +35,17 @@ namespace detail
template <typename T> template <typename T>
struct tquat// : public genType<T, tquat> struct tquat// : public genType<T, tquat>
{ {
typedef T value_type;
enum ctor{null};
typedef T value_type;
typedef std::size_t size_type;
public: public:
value_type x, y, z, w; value_type x, y, z, w;
GLM_FUNC_DECL size_type length() const;
// Constructors // Constructors
tquat(); tquat();
explicit tquat( explicit tquat(

@ -8,17 +8,32 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp>
int test_length_mat_non_squared() int test_length_mat_non_squared()
{ {
int Error = 0; int Error = 0;
Error += glm::mat2x3().length() == 6 ? 0 : 1; Error += glm::mat2x3().length() == 2 ? 0 : 1;
Error += glm::mat2x4().length() == 8 ? 0 : 1; Error += glm::mat2x4().length() == 2 ? 0 : 1;
Error += glm::mat3x2().length() == 6 ? 0 : 1; Error += glm::mat3x2().length() == 3 ? 0 : 1;
Error += glm::mat3x4().length() == 12 ? 0 : 1; Error += glm::mat3x4().length() == 3 ? 0 : 1;
Error += glm::mat4x2().length() == 8 ? 0 : 1; Error += glm::mat4x2().length() == 4 ? 0 : 1;
Error += glm::mat4x3().length() == 12 ? 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; return Error;
} }
@ -27,12 +42,26 @@ int test_length_mat()
{ {
int Error = 0; int Error = 0;
Error += glm::mat2().length() == 4 ? 0 : 1; Error += glm::mat2().length() == 2 ? 0 : 1;
Error += glm::mat3().length() == 9 ? 0 : 1; Error += glm::mat3().length() == 3 ? 0 : 1;
Error += glm::mat4().length() == 16 ? 0 : 1; Error += glm::mat4().length() == 4 ? 0 : 1;
Error += glm::mat2x2().length() == 4 ? 0 : 1; Error += glm::mat2x2().length() == 2 ? 0 : 1;
Error += glm::mat3x3().length() == 9 ? 0 : 1; Error += glm::mat3x3().length() == 3 ? 0 : 1;
Error += glm::mat4x4().length() == 16 ? 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; return Error;
} }
@ -46,6 +75,22 @@ int test_length_vec()
Error += glm::vec3().length() == 3 ? 0 : 1; Error += glm::vec3().length() == 3 ? 0 : 1;
Error += glm::vec4().length() == 4 ? 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; return Error;
} }

Loading…
Cancel
Save