Added GTX_scalar_relational implementation and tests
This commit is contained in:
parent
c57a000791
commit
59b9a780e9
60
glm/gtx/scalar_relational.hpp
Normal file
60
glm/gtx/scalar_relational.hpp
Normal file
@ -0,0 +1,60 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtx_scalar_relational
|
||||
/// @file glm/gtx/scalar_relational.hpp
|
||||
/// @date 2013-02-04 / 2013-02-04
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtx_extend GLM_GTX_scalar_relational
|
||||
/// @ingroup gtx
|
||||
///
|
||||
/// @brief Extend a position from a source to a position at a defined length.
|
||||
///
|
||||
/// <glm/gtx/scalar_relational.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTX_scalar_relational
|
||||
#define GLM_GTX_scalar_relational GLM_VERSION
|
||||
|
||||
// Dependency:
|
||||
#include "../glm.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
|
||||
# pragma message("GLM: GLM_GTX_extend extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// @addtogroup gtx_scalar_relational
|
||||
/// @{
|
||||
|
||||
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "scalar_relational.inl"
|
||||
|
||||
#endif//GLM_GTX_scalar_relational
|
97
glm/gtx/scalar_relational.inl
Normal file
97
glm/gtx/scalar_relational.inl
Normal file
@ -0,0 +1,97 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2013-02-04
|
||||
// Updated : 2013-02-04
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/scalar_relational.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool lessThan
|
||||
(
|
||||
T const & x,
|
||||
T const & y
|
||||
)
|
||||
{
|
||||
return x < y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool lessThanEqual
|
||||
(
|
||||
T const & x,
|
||||
T const & y
|
||||
)
|
||||
{
|
||||
return x <= y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool greaterThan
|
||||
(
|
||||
T const & x,
|
||||
T const & y
|
||||
)
|
||||
{
|
||||
return x > y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool greaterThanEqual
|
||||
(
|
||||
T const & x,
|
||||
T const & y
|
||||
)
|
||||
{
|
||||
return x >= y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool equal
|
||||
(
|
||||
T const & x,
|
||||
T const & y
|
||||
)
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER bool notEqual
|
||||
(
|
||||
T const & x,
|
||||
T const & y
|
||||
)
|
||||
{
|
||||
return x != y;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER bool any
|
||||
(
|
||||
bool const & x,
|
||||
bool const & y
|
||||
)
|
||||
{
|
||||
return x || y;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER bool all
|
||||
(
|
||||
bool const & x,
|
||||
bool const & y
|
||||
)
|
||||
{
|
||||
return x && y;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER bool not_
|
||||
(
|
||||
bool const & x
|
||||
)
|
||||
{
|
||||
return !x;
|
||||
}
|
||||
}//namespace glm
|
@ -41,6 +41,7 @@ GLM 0.9.5.X: 2013-XX-XX
|
||||
--------------------------------------------------------------------------------
|
||||
- Improved Intel Compiler detection
|
||||
- Added bitfieldInterleave and _mm_bit_interleave_si128 functions
|
||||
- Added GTX_scalar_relational
|
||||
|
||||
================================================================================
|
||||
GLM 0.9.4.2: 2013-01-XX
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
int Failed = 0;
|
||||
int Error(0);
|
||||
|
||||
return Failed;
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ glmCreateTestGTC(gtx_multiple)
|
||||
glmCreateTestGTC(gtx_quaternion)
|
||||
glmCreateTestGTC(gtx_rotate_normalized_axis)
|
||||
glmCreateTestGTC(gtx_rotate_vector)
|
||||
glmCreateTestGTC(gtx_scalar_relational)
|
||||
glmCreateTestGTC(gtx_simd_vec4)
|
||||
glmCreateTestGTC(gtx_simd_mat4)
|
||||
glmCreateTestGTC(gtx_string_cast)
|
||||
|
183
test/gtx/gtx_scalar_relational.cpp
Normal file
183
test/gtx/gtx_scalar_relational.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2013-02-04
|
||||
// Updated : 2013-02-04
|
||||
// Licence : This source is under MIT licence
|
||||
// File : test/gtx/gtx_scalar_relational.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/scalar_relational.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
int test_lessThan()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::lessThan(0, 1) ? 0 : 1;
|
||||
Error += glm::lessThan(1, 0) ? 1 : 0;
|
||||
Error += glm::lessThan(0, 0) ? 1 : 0;
|
||||
Error += glm::lessThan(1, 1) ? 1 : 0;
|
||||
Error += glm::lessThan(0.0f, 1.0f) ? 0 : 1;
|
||||
Error += glm::lessThan(1.0f, 0.0f) ? 1 : 0;
|
||||
Error += glm::lessThan(0.0f, 0.0f) ? 1 : 0;
|
||||
Error += glm::lessThan(1.0f, 1.0f) ? 1 : 0;
|
||||
Error += glm::lessThan(0.0, 1.0) ? 0 : 1;
|
||||
Error += glm::lessThan(1.0, 0.0) ? 1 : 0;
|
||||
Error += glm::lessThan(0.0, 0.0) ? 1 : 0;
|
||||
Error += glm::lessThan(1.0, 1.0) ? 1 : 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_lessThanEqual()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::lessThanEqual(0, 1) ? 0 : 1;
|
||||
Error += glm::lessThanEqual(1, 0) ? 1 : 0;
|
||||
Error += glm::lessThanEqual(0, 0) ? 0 : 1;
|
||||
Error += glm::lessThanEqual(1, 1) ? 0 : 1;
|
||||
Error += glm::lessThanEqual(0.0f, 1.0f) ? 0 : 1;
|
||||
Error += glm::lessThanEqual(1.0f, 0.0f) ? 1 : 0;
|
||||
Error += glm::lessThanEqual(0.0f, 0.0f) ? 0 : 1;
|
||||
Error += glm::lessThanEqual(1.0f, 1.0f) ? 0 : 1;
|
||||
Error += glm::lessThanEqual(0.0, 1.0) ? 0 : 1;
|
||||
Error += glm::lessThanEqual(1.0, 0.0) ? 1 : 0;
|
||||
Error += glm::lessThanEqual(0.0, 0.0) ? 0 : 1;
|
||||
Error += glm::lessThanEqual(1.0, 1.0) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_greaterThan()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::greaterThan(0, 1) ? 1 : 0;
|
||||
Error += glm::greaterThan(1, 0) ? 0 : 1;
|
||||
Error += glm::greaterThan(0, 0) ? 1 : 0;
|
||||
Error += glm::greaterThan(1, 1) ? 1 : 0;
|
||||
Error += glm::greaterThan(0.0f, 1.0f) ? 1 : 0;
|
||||
Error += glm::greaterThan(1.0f, 0.0f) ? 0 : 1;
|
||||
Error += glm::greaterThan(0.0f, 0.0f) ? 1 : 0;
|
||||
Error += glm::greaterThan(1.0f, 1.0f) ? 1 : 0;
|
||||
Error += glm::greaterThan(0.0, 1.0) ? 1 : 0;
|
||||
Error += glm::greaterThan(1.0, 0.0) ? 0 : 1;
|
||||
Error += glm::greaterThan(0.0, 0.0) ? 1 : 0;
|
||||
Error += glm::greaterThan(1.0, 1.0) ? 1 : 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_greaterThanEqual()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::greaterThanEqual(0, 1) ? 1 : 0;
|
||||
Error += glm::greaterThanEqual(1, 0) ? 0 : 1;
|
||||
Error += glm::greaterThanEqual(0, 0) ? 0 : 1;
|
||||
Error += glm::greaterThanEqual(1, 1) ? 0 : 1;
|
||||
Error += glm::greaterThanEqual(0.0f, 1.0f) ? 1 : 0;
|
||||
Error += glm::greaterThanEqual(1.0f, 0.0f) ? 0 : 1;
|
||||
Error += glm::greaterThanEqual(0.0f, 0.0f) ? 0 : 1;
|
||||
Error += glm::greaterThanEqual(1.0f, 1.0f) ? 0 : 1;
|
||||
Error += glm::greaterThanEqual(0.0, 1.0) ? 1 : 0;
|
||||
Error += glm::greaterThanEqual(1.0, 0.0) ? 0 : 1;
|
||||
Error += glm::greaterThanEqual(0.0, 0.0) ? 0 : 1;
|
||||
Error += glm::greaterThanEqual(1.0, 1.0) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_equal()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::equal(0, 1) ? 1 : 0;
|
||||
Error += glm::equal(1, 0) ? 1 : 0;
|
||||
Error += glm::equal(0, 0) ? 0 : 1;
|
||||
Error += glm::equal(1, 1) ? 0 : 1;
|
||||
Error += glm::equal(0.0f, 1.0f) ? 1 : 0;
|
||||
Error += glm::equal(1.0f, 0.0f) ? 1 : 0;
|
||||
Error += glm::equal(0.0f, 0.0f) ? 0 : 1;
|
||||
Error += glm::equal(1.0f, 1.0f) ? 0 : 1;
|
||||
Error += glm::equal(0.0, 1.0) ? 1 : 0;
|
||||
Error += glm::equal(1.0, 0.0) ? 1 : 0;
|
||||
Error += glm::equal(0.0, 0.0) ? 0 : 1;
|
||||
Error += glm::equal(1.0, 1.0) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_notEqual()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::notEqual(0, 1) ? 0 : 1;
|
||||
Error += glm::notEqual(1, 0) ? 0 : 1;
|
||||
Error += glm::notEqual(0, 0) ? 1 : 0;
|
||||
Error += glm::notEqual(1, 1) ? 1 : 0;
|
||||
Error += glm::notEqual(0.0f, 1.0f) ? 0 : 1;
|
||||
Error += glm::notEqual(1.0f, 0.0f) ? 0 : 1;
|
||||
Error += glm::notEqual(0.0f, 0.0f) ? 1 : 0;
|
||||
Error += glm::notEqual(1.0f, 1.0f) ? 1 : 0;
|
||||
Error += glm::notEqual(0.0, 1.0) ? 0 : 1;
|
||||
Error += glm::notEqual(1.0, 0.0) ? 0 : 1;
|
||||
Error += glm::notEqual(0.0, 0.0) ? 1 : 0;
|
||||
Error += glm::notEqual(1.0, 1.0) ? 1 : 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_any()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::any(true, true) ? 0 : 1;
|
||||
Error += glm::any(true, false) ? 0 : 1;
|
||||
Error += glm::any(false, true) ? 0 : 1;
|
||||
Error += glm::any(false, false) ? 1 : 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_all()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::all(true, true) ? 0 : 1;
|
||||
Error += glm::all(true, false) ? 1 : 0;
|
||||
Error += glm::all(false, true) ? 1 : 0;
|
||||
Error += glm::all(false, false) ? 1 : 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_not()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += glm::not_(true) ? 1 : 0;
|
||||
Error += glm::not_(false) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_lessThan();
|
||||
Error += test_lessThanEqual();
|
||||
Error += test_greaterThan();
|
||||
Error += test_greaterThanEqual();
|
||||
Error += test_equal();
|
||||
Error += test_notEqual();
|
||||
Error += test_any();
|
||||
Error += test_all();
|
||||
Error += test_not();
|
||||
|
||||
return Error;
|
||||
}
|
Loading…
Reference in New Issue
Block a user