///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-08-03
// Updated : 2008-09-09
// Licence : This source is under MIT License
// File : glm/core/func_vector_relational.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_core_func_vector_relational
#define glm_core_func_vector_relational
#include "_detail.hpp"
namespace glm
{
namespace test{
void main_core_func_vector_relational();
}//namespace test
namespace core{
namespace function{
//! Define vector relational functions from Section 8.6 of GLSL 1.30.8 specification.
//! Included in glm namespace.
namespace vector_relational
{
/// \addtogroup core_funcs
///@{
//! Returns the component-wise comparison result of x < y.
//!
//! \li GLSL lessThan man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline typename vecType::bool_type lessThan
(
vecType const & x,
vecType const & y
)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'lessThan', GLM vector types required");
GLM_STATIC_ASSERT(detail::is_bool::_NO,
"Invalid template instantiation of 'lessThan', GLM vector types required floating-point or integer value types vectors");
typename vecType::bool_type Result(vecType::null);
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result[i] = x[i] < y[i];
return Result;
}
//! Returns the component-wise comparison of result x <= y.
//!
//! \li GLSL lessThanEqual man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline typename vecType::bool_type lessThanEqual
(
vecType const & x,
vecType const & y
)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'lessThanEqual', GLM vector types required");
GLM_STATIC_ASSERT(detail::is_bool::_NO,
"Invalid template instantiation of 'lessThanEqual', GLM vector types required floating-point or integer value types vectors");
typename vecType::bool_type Result(vecType::null);
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result[i] = x[i] <= y[i];
return Result;
}
//! Returns the component-wise comparison of result x > y.
//!
//! \li GLSL greaterThan man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline typename vecType::bool_type greaterThan
(
vecType const & x,
vecType const & y
)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'greaterThan', GLM vector types required");
GLM_STATIC_ASSERT(detail::is_bool::_NO,
"Invalid template instantiation of 'greaterThan', GLM vector types required floating-point or integer value types vectors");
typename vecType::bool_type Result(vecType::null);
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result[i] = x[i] > y[i];
return Result;
}
//! Returns the component-wise comparison of result x >= y.
//!
//! \li GLSL greaterThanEqual man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline typename vecType::bool_type greaterThanEqual
(
vecType const & x,
vecType const & y
)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'greaterThanEqual', GLM vector types required");
GLM_STATIC_ASSERT(detail::is_bool::_NO,
"Invalid template instantiation of 'greaterThanEqual', GLM vector types required floating-point or integer value types vectors");
typename vecType::bool_type Result(vecType::null);
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result[i] = x[i] >= y[i];
return Result;
}
//! Returns the component-wise comparison of result x == y.
//!
//! \li GLSL equal man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline typename vecType::bool_type equal
(
vecType const & x,
vecType const & y
)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'equal', GLM vector types required");
typename vecType::bool_type Result(vecType::null);
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result[i] = x[i] == y[i];
return Result;
}
//! Returns the component-wise comparison of result x != y.
//!
//! \li GLSL notEqual man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline typename vecType::bool_type notEqual
(
vecType const & x,
vecType const & y
)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'notEqual', GLM vector types required");
typename vecType::bool_type Result(vecType::null);
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result[i] = x[i] != y[i];
return Result;
}
//! Returns true if any component of x is true.
//!
//! \li GLSL any man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline bool any(vecType const & v)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'any', GLM boolean vector types required");
bool Result = false;
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result = Result || v[i];
return Result;
}
//! Returns true if all components of x are true.
//!
//! \li GLSL all man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline bool all(vecType const & v)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'all', GLM boolean vector types required");
bool Result = true;
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result = Result && v[i];
return Result;
}
//! Returns the component-wise logical complement of x.
//! /!\ Because of language incompatibilities between C++ and GLSL, GLM defines the function not but not_ instead.
//!
//! \li GLSL not man page
//! \li GLSL 1.30.08 specification, section 8.6
template class vecType>
inline vecType not_(vecType const & v)
{
GLM_STATIC_ASSERT(detail::is_vector >::_YES,
"Invalid template instantiation of 'not_', GLM vector types required");
typename vecType::bool_type Result(vecType::null);
for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i)
Result[i] = !v[i];
return Result;
}
///@}
}//namespace vector_relational
}//namespace function
}//namespace core
using namespace core::function::vector_relational;
}//namespace glm
#include "func_vector_relational.inl"
#endif//glm_core_func_vector_relational