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 #include "_detail.hpp"
00014 
00015 namespace glm
00016 {
00017         namespace core{
00018         namespace function{
00021         namespace vector_relational
00022         {
00025 
00030         template <typename T, template <typename> class vecType> 
00031                 GLM_FUNC_QUALIFIER typename vecType<T>::bool_type lessThan
00032                 (
00033                         vecType<T> const & x, 
00034                         vecType<T> const & y
00035                 )
00036                 {
00037                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00038                                 "Invalid template instantiation of 'lessThan', GLM vector types required");
00039                         GLM_STATIC_ASSERT(detail::is_bool<T>::_NO,
00040                                 "Invalid template instantiation of 'lessThan', GLM vector types required floating-point or integer value types vectors");
00041 
00042                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00043                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00044                                 Result[i] = x[i] < y[i];
00045 
00046                         return Result;
00047                 }
00048 
00053                 template <typename T, template <typename> class vecType> 
00054                 GLM_FUNC_QUALIFIER typename vecType<T>::bool_type lessThanEqual
00055                 (
00056                         vecType<T> const & x, 
00057                         vecType<T> const & y
00058                 )
00059                 {
00060                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00061                                 "Invalid template instantiation of 'lessThanEqual', GLM vector types required");
00062                         GLM_STATIC_ASSERT(detail::is_bool<T>::_NO, 
00063                                 "Invalid template instantiation of 'lessThanEqual', GLM vector types required floating-point or integer value types vectors");
00064 
00065                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00066                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00067                                 Result[i] = x[i] <= y[i];
00068                         return Result;
00069                 }
00070 
00075                 template <typename T, template <typename> class vecType> 
00076                 GLM_FUNC_QUALIFIER typename vecType<T>::bool_type greaterThan
00077                 (
00078                         vecType<T> const & x, 
00079                         vecType<T> const & y
00080                 )
00081                 {
00082                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00083                                 "Invalid template instantiation of 'greaterThan', GLM vector types required");
00084                         GLM_STATIC_ASSERT(detail::is_bool<T>::_NO, 
00085                                 "Invalid template instantiation of 'greaterThan', GLM vector types required floating-point or integer value types vectors");
00086 
00087                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00088                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00089                                 Result[i] = x[i] > y[i];
00090                         return Result;
00091                 }
00092 
00097                 template <typename T, template <typename> class vecType> 
00098                 GLM_FUNC_QUALIFIER typename vecType<T>::bool_type greaterThanEqual
00099                 (
00100                         vecType<T> const & x, 
00101                         vecType<T> const & y
00102                 )
00103                 {
00104                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00105                                 "Invalid template instantiation of 'greaterThanEqual', GLM vector types required");
00106                         GLM_STATIC_ASSERT(detail::is_bool<T>::_NO, 
00107                                 "Invalid template instantiation of 'greaterThanEqual', GLM vector types required floating-point or integer value types vectors");
00108 
00109                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00110                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00111                                 Result[i] = x[i] >= y[i];
00112                         return Result;
00113                 }
00114 
00119                 template <typename T, template <typename> class vecType> 
00120                 GLM_FUNC_QUALIFIER typename vecType<T>::bool_type equal
00121                 (
00122                         vecType<T> const & x, 
00123                         vecType<T> const & y
00124                 )
00125                 {
00126                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00127                                 "Invalid template instantiation of 'equal', GLM vector types required");
00128 
00129                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00130                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00131                                 Result[i] = x[i] == y[i];
00132                         return Result;
00133                 }
00134 
00139                 template <typename T, template <typename> class vecType> 
00140                 GLM_FUNC_QUALIFIER typename vecType<T>::bool_type notEqual
00141                 (
00142                         vecType<T> const & x, 
00143                         vecType<T> const & y
00144                 )
00145                 {
00146                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00147                                 "Invalid template instantiation of 'notEqual', GLM vector types required");
00148 
00149                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00150                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00151                                 Result[i] = x[i] != y[i];
00152                         return Result;
00153                 }
00154 
00159                 template <template <typename> class vecType> 
00160                 GLM_FUNC_QUALIFIER bool any(vecType<bool> const & v)
00161                 {
00162                         GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00163                                 "Invalid template instantiation of 'any', GLM boolean vector types required");
00164 
00165                         bool Result = false;
00166                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00167                                 Result = Result || v[i];
00168                         return Result;
00169                 }
00170 
00175                 template <template <typename> class vecType> 
00176                 GLM_FUNC_QUALIFIER bool all(vecType<bool> const & v)
00177                 {
00178                         GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00179                                 "Invalid template instantiation of 'all', GLM boolean vector types required");
00180 
00181                         bool Result = true;
00182                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00183                                 Result = Result && v[i];
00184                         return Result;
00185                 }
00186 
00192                 template <template <typename> class vecType> 
00193                 GLM_FUNC_QUALIFIER vecType<bool> not_(vecType<bool> const & v)
00194                 {
00195                         GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00196                                 "Invalid template instantiation of 'not_', GLM vector types required");
00197 
00198                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00199                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00200                                 Result[i] = !v[i];
00201                         return Result;
00202                 }
00203 
00205 
00206         }//namespace vector_relational
00207         }//namespace function
00208         }//namespace core
00209 
00210         using namespace core::function::vector_relational;
00211 }//namespace glm
00212 
00213 #include "func_vector_relational.inl"
00214 
00215 #endif//glm_core_func_vector_relational