Fixed ticket #153, vector and matrix queries

This commit is contained in:
Christophe Riccio 2011-12-06 12:22:43 +00:00
parent dd244d8d25
commit 7ff95df5e6
7 changed files with 115 additions and 54 deletions

View File

@ -4,6 +4,7 @@
<downloads>
<section name="GLM - zip files">
<download name="GLM 0.9.2.7" date="24/10/2011" size="3.4 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.2.7/glm-0.9.2.7.zip/download"/>
<download name="GLM 0.9.3.B" date="06/12/2011" size="4.3 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.3.B/glm-0.9.3.B.zip/download"/>
<download name="GLM 0.9.3.A" date="11/11/2011" size="4.3 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.3.A/glm-0.9.3.A.zip/download"/>
<download name="GLM 0.9.2.6" date="01/10/2011" size="3.4 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.2.6/glm-0.9.2.6.zip/download"/>
<download name="GLM 0.9.2.5" date="20/09/2011" size="3.4 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.2.5/glm-0.9.2.5.zip/download"/>
@ -72,6 +73,7 @@
</section>
<section name="GLM - 7z files">
<download name="GLM 0.9.2.7" date="24/10/2011" size="2.1 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.2.7/glm-0.9.2.7.7z/download"/>
<download name="GLM 0.9.3.B" date="06/12/2011" size="2.8 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.3.B/glm-0.9.3.B.7z/download"/>
<download name="GLM 0.9.3.A" date="11/11/2011" size="2.8 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.3.A/glm-0.9.3.A.7z/download"/>
<download name="GLM 0.9.2.6" date="01/10/2011" size="2.1 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.2.6/glm-0.9.2.6.7z/download"/>
<download name="GLM 0.9.2.5" date="20/09/2011" size="2.1 MB" link="https://sourceforge.net/projects/ogl-math/files/glm-0.9.2.5/glm-0.9.2.5.7z/download"/>
@ -166,6 +168,50 @@
</todo>
<page_news>
<news index="0074" date="06/12/2011" title="GLM 0.9.3 beta released" image="goodies/logo.png" image-mini="image/logo-mini.png">
<paragraph>
GLM 0.9.3 is making progress which is illustrated by the release of this first alpha.
</paragraph>
<list name="Changelog:">
<list-element>
Improved doxygen documentation
</list-element>
<list-element>
Added new swizzle operators for C++11 compilers
</list-element>
<list-element>
Added new swizzle operators declared as functions
</list-element>
<list-element>
Added GLSL 4.20 length for vector and matrix types
</list-element>
<list-element>
Added GLSL core noise functions
</list-element>
<list-element>
Promoted GLM_GTC_noise extension: simplex, perlin, periodic noise functions
</list-element>
<list-element>
Promoted GLM_GTC_random extension: linear, gaussian and various random number generation distribution
</list-element>
<list-element>
Added GLM_GTX_constants: provides usefull constants
</list-element>
<list-element>
Fixed half based type contructors
</list-element>
</list>
<paragraph>
</paragraph>
<source type="Download" href="https://sourceforge.net/projects/ogl-math/files/glm-0.9.3.B/glm-0.9.3.B.zip/download">GLM 0.9.3.B (zip)</source>
<source type="Download" href="https://sourceforge.net/projects/ogl-math/files/glm-0.9.3.B/glm-0.9.3.B.7z/download">GLM 0.9.3.B (7z)</source>
<source type="Link" href="https://sourceforge.net/apps/trac/ogl-math/newticket">Submit a bug report</source>
<source type="Link" href="http://glm.g-truc.net/glm-0.9.3.pdf">GLM 0.9.3 Manual</source>
<source type="Link" href="http://glm.g-truc.net/api-0.9.3/index.html">GLM 0.9.3 API</source>
</news>
<news index="0073" date="11/11/2011" title="GLM 0.9.3 alpha released" image="goodies/logo.png" image-mini="image/logo-mini.png">
<paragraph>
GLM 0.9.3 is making progress which is illustrated by the release of this first alpha.

View File

@ -58,13 +58,13 @@ namespace glm
)
{
bool result = true;
for(typename genType::value_type i = typename genType::value_type(0); result && i < genType::col_size(); ++i)
for(typename genType::size_type i = typename genType::size_type(0); result && i < genType::col_size(); ++i)
{
for(typename genType::value_type j = typename genType::value_type(0); result && j < i ; ++j)
for(typename genType::size_type j = typename genType::size_type(0); result && j < i ; ++j)
result = abs(m[i][j]) <= epsilon;
if(result)
result = abs(m[i][i] - typename genType::value_type(1)) <= epsilon;
for(typename genType::value_type j = i + typename genType::value_type(1); result && j < genType::row_size(); ++j)
for(typename genType::size_type j = i + typename genType::size_type(1); result && j < genType::row_size(); ++j)
result = abs(m[i][j]) <= epsilon;
}
return result;

View File

@ -60,14 +60,6 @@ namespace glm
genType const & v1,
typename genType::value_type const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/);
//! Check whether two vectors are opposites.
//! From GLM_GTX_vector_query extensions.
template <typename genType>
bool areOpposite(
genType const & v0,
genType const & v1,
typename genType::value_type const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/);
//! Check whether two vectors are orthogonals.
//! From GLM_GTX_vector_query extensions.
template <typename genType>
@ -112,14 +104,6 @@ namespace glm
genType const & v1,
typename genType::value_type const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/);
//! Check whether two vectors are similar.
//! From GLM_GTX_vector_query extensions.
template <typename genType>
bool areSimilar(
genType const & v0,
genType const & v1,
typename genType::value_type const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/);
/// @}
}// namespace glm

View File

@ -19,7 +19,7 @@ namespace glm
(
detail::tvec2<T> const & v0,
detail::tvec2<T> const & v1,
T const & epsilon
typename detail::tvec2<T>::value_type const & epsilon
)
{
return length(cross(detail::tvec3<T>(v0, T(0)), detail::tvec3<T>(v1, T(0)))) < epsilon;
@ -30,7 +30,7 @@ namespace glm
(
detail::tvec3<T> const & v0,
detail::tvec3<T> const & v1,
T const & epsilon
typename detail::tvec3<T>::value_type const & epsilon
)
{
return length(cross(v0, v1)) < epsilon;
@ -41,24 +41,12 @@ namespace glm
(
detail::tvec4<T> const & v0,
detail::tvec4<T> const & v1,
T const & epsilon
typename detail::tvec4<T>::value_type const & epsilon
)
{
return length(cross(detail::tvec3<T>(v0), detail::tvec3<T>(v1))) < epsilon;
}
template <typename genType>
GLM_FUNC_QUALIFIER bool areOpposite
(
genType const & v0,
genType const & v1,
typename genType::value_type const & epsilon
)
{
assert(isNormalized(v0) && isNormalized(v1));
return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon);
}
template <typename genType>
GLM_FUNC_QUALIFIER bool areOrthogonal
(
@ -173,17 +161,4 @@ namespace glm
return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon);
}
template <typename genType>
GLM_FUNC_QUALIFIER bool areSimilar
(
genType const & v0,
genType const & v1,
typename genType::value_type const & epsilon
)
{
bool similar = true;
for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++)
similar = (abs(v0[i] - v1[i]) <= epsilon);
return similar;
}
}//namespace glm

View File

@ -37,11 +37,12 @@ More informations in GLM manual:
http://glm.g-truc.net/glm-0.9.3.pdf
================================================================================
GLM 0.9.3.B: 2011-XX-XX
GLM 0.9.3.B: 2011-12-06
--------------------------------------------------------------------------------
- Added support for Chrone Native Client
- Added epsilon constant
- Removed value_size function from vector types
- Fixed roundEven on GCC
================================================================================
GLM 0.9.2.8: 2011-12-XX

View File

@ -20,6 +20,26 @@ int test_isNull()
return Error;
}
int test_isIdentity()
{
int Error(0);
{
bool TestA = glm::isIdentity(glm::mat2(1), 0.00001f);
Error += TestA ? 0 : 1;
}
{
bool TestA = glm::isIdentity(glm::mat3(1), 0.00001f);
Error += TestA ? 0 : 1;
}
{
bool TestA = glm::isIdentity(glm::mat4(1), 0.00001f);
Error += TestA ? 0 : 1;
}
return Error;
}
int test_isNormalized()
{
int Error(0);
@ -45,6 +65,7 @@ int main()
int Error(0);
Error += test_isNull();
Error += test_isIdentity();
Error += test_isNormalized();
Error += test_isOrthogonal();

View File

@ -10,11 +10,33 @@
#include <glm/glm.hpp>
#include <glm/gtx/vector_query.hpp>
int test_isNull()
int test_areCollinear()
{
int Error(0);
{
bool TestA = glm::areCollinear(glm::vec2(-1), glm::vec2(1), 0.00001f);
Error += TestA ? 0 : 1;
}
{
bool TestA = glm::areCollinear(glm::vec3(-1), glm::vec3(1), 0.00001f);
Error += TestA ? 0 : 1;
}
{
bool TestA = glm::areCollinear(glm::vec4(-1), glm::vec4(1), 0.00001f);
Error += TestA ? 0 : 1;
}
return Error;
}
int test_areOrthogonal()
{
int Error(0);
bool TestA = glm::isNull(glm::vec4(0), 0.00001f);
bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
@ -30,11 +52,21 @@ int test_isNormalized()
return Error;
}
int test_areOrthogonal()
int test_isNull()
{
int Error(0);
bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
bool TestA = glm::isNull(glm::vec4(0), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
}
int test_areOrthonormal()
{
int Error(0);
bool TestA = glm::areOrthonormal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f);
Error += TestA ? 0 : 1;
return Error;
@ -44,9 +76,11 @@ int main()
{
int Error(0);
Error += test_isNull();
Error += test_isNormalized();
Error += test_areCollinear();
Error += test_areOrthogonal();
Error += test_isNormalized();
Error += test_isNull();
Error += test_areOrthonormal();
return Error;
}