GLM Version 0.9.0

func_vector_relational.hpp

00001 
00002 // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
00004 // Created : 2008-08-03
00005 // Updated : 2008-09-09
00006 // Licence : This source is under MIT License
00007 // File    : glm/core/func_vector_relational.hpp
00009 
00010 #ifndef glm_core_func_vector_relational
00011 #define glm_core_func_vector_relational
00012 
00013 namespace glm
00014 {
00015         namespace test{
00016                 void main_core_func_vector_relational();
00017         }//namespace test
00018 
00019         namespace core{
00020         namespace function{
00023         namespace vector_relational
00024         {
00027                 template <typename T, template <typename> class vecType> 
00028                 inline typename vecType<T>::bool_type lessThan
00029                 (
00030                         vecType<T> const & x, 
00031                         vecType<T> const & y
00032                 )
00033                 {
00034                         GLM_STATIC_ASSERT(
00035                                 detail::type<T>::is_float || 
00036                                 detail::type<T>::is_int || 
00037                                 detail::type<T>::is_uint);
00038 
00039                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00040                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00041                                 Result[i] = x[i] < y[i];
00042                         return Result;
00043                 }
00044 
00047                 template <typename T, template <typename> class vecType> 
00048                 inline typename vecType<T>::bool_type lessThanEqual
00049                 (
00050                         vecType<T> const & x, 
00051                         vecType<T> const & y
00052                 )
00053                 {
00054                         GLM_STATIC_ASSERT(
00055                                 detail::type<T>::is_float || 
00056                                 detail::type<T>::is_int || 
00057                                 detail::type<T>::is_uint);
00058 
00059                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00060                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00061                                 Result[i] = x[i] <= y[i];
00062                         return Result;
00063                 }
00064 
00067                 template <typename T, template <typename> class vecType> 
00068                 inline typename vecType<T>::bool_type greaterThan
00069                 (
00070                         vecType<T> const & x, 
00071                         vecType<T> const & y
00072                 )
00073                 {
00074                         GLM_STATIC_ASSERT(
00075                                 detail::type<T>::is_float || 
00076                                 detail::type<T>::is_int || 
00077                                 detail::type<T>::is_uint);
00078 
00079                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00080                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00081                                 Result[i] = x[i] > y[i];
00082                         return Result;
00083                 }
00084 
00087                 template <typename T, template <typename> class vecType> 
00088                 inline typename vecType<T>::bool_type greaterThanEqual
00089                 (
00090                         vecType<T> const & x, 
00091                         vecType<T> const & y
00092                 )
00093                 {
00094                         GLM_STATIC_ASSERT(
00095                                 detail::type<T>::is_float || 
00096                                 detail::type<T>::is_int || 
00097                                 detail::type<T>::is_uint);
00098 
00099                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00100                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00101                                 Result[i] = x[i] >= y[i];
00102                         return Result;
00103                 }
00104 
00107                 template <typename T, template <typename> class vecType> 
00108                 inline typename vecType<T>::bool_type equal
00109                 (
00110                         vecType<T> const & x, 
00111                         vecType<T> const & y
00112                 )
00113                 {
00114                         GLM_STATIC_ASSERT(
00115                                 detail::type<T>::is_float || 
00116                                 detail::type<T>::is_int || 
00117                                 detail::type<T>::is_uint || 
00118                                 detail::type<T>::is_bool);
00119 
00120                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00121                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00122                                 Result[i] = x[i] == y[i];
00123                         return Result;
00124                 }
00125 
00128                 template <typename T, template <typename> class vecType> 
00129                 inline typename vecType<T>::bool_type notEqual
00130                 (
00131                         vecType<T> const & x, 
00132                         vecType<T> const & y
00133                 )
00134                 {
00135                         GLM_STATIC_ASSERT(
00136                                 detail::type<T>::is_float || 
00137                                 detail::type<T>::is_int || 
00138                                 detail::type<T>::is_uint || 
00139                                 detail::type<T>::is_bool);
00140 
00141                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00142                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00143                                 Result[i] = x[i] != y[i];
00144                         return Result;
00145                 }
00146 
00149                 template <template <typename> class vecType> 
00150                 inline bool any(vecType<bool> const & v)
00151                 {
00152                         bool Result = false;
00153                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00154                                 Result = Result || v[i];
00155                         return Result;
00156                 }
00157 
00160                 template <template <typename> class vecType> 
00161                 inline bool all(vecType<bool> const & v)
00162                 {
00163                         bool Result = true;
00164                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00165                                 Result = Result && v[i];
00166                         return Result;
00167                 }
00168 
00171                 template <template <typename> class vecType> 
00172                 inline vecType<bool> not_(vecType<bool> const & v)
00173                 {
00174                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00175                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00176                                 Result[i] = !v[i];
00177                         return Result;
00178                 }
00179 
00180         }//namespace vector_relational
00181         }//namespace function
00182         }//namespace core
00183 
00184         using namespace core::function::vector_relational;
00185 }//namespace glm
00186 
00187 #include "func_vector_relational.inl"
00188 
00189 #endif//glm_core_func_vector_relational