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 test{
00018                 void main_core_func_vector_relational();
00019         }//namespace test
00020 
00021         namespace core{
00022         namespace function{
00025         namespace vector_relational
00026         {
00029 
00032                 template <typename T, template <typename> class vecType> 
00033                 inline typename vecType<T>::bool_type lessThan
00034                 (
00035                         vecType<T> const & x, 
00036                         vecType<T> const & y
00037                 )
00038                 {
00039                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00040                                 "Invalid template instantiation of 'lessThan', GLM vector types required");
00041                         GLM_STATIC_ASSERT(detail::is_bool<T>::_NO,
00042                                 "Invalid template instantiation of 'lessThan', GLM vector types required floating-point or integer value types vectors");
00043 
00044                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00045                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00046                                 Result[i] = x[i] < y[i];
00047 
00048                         return Result;
00049                 }
00050 
00053                 template <typename T, template <typename> class vecType> 
00054                 inline 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 
00073                 template <typename T, template <typename> class vecType> 
00074                 inline typename vecType<T>::bool_type greaterThan
00075                 (
00076                         vecType<T> const & x, 
00077                         vecType<T> const & y
00078                 )
00079                 {
00080                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00081                                 "Invalid template instantiation of 'greaterThan', GLM vector types required");
00082                         GLM_STATIC_ASSERT(detail::is_bool<T>::_NO, 
00083                                 "Invalid template instantiation of 'greaterThan', GLM vector types required floating-point or integer value types vectors");
00084 
00085                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00086                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00087                                 Result[i] = x[i] > y[i];
00088                         return Result;
00089                 }
00090 
00093                 template <typename T, template <typename> class vecType> 
00094                 inline typename vecType<T>::bool_type greaterThanEqual
00095                 (
00096                         vecType<T> const & x, 
00097                         vecType<T> const & y
00098                 )
00099                 {
00100                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00101                                 "Invalid template instantiation of 'greaterThanEqual', GLM vector types required");
00102                         GLM_STATIC_ASSERT(detail::is_bool<T>::_NO, 
00103                                 "Invalid template instantiation of 'greaterThanEqual', GLM vector types required floating-point or integer value types vectors");
00104 
00105                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00106                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00107                                 Result[i] = x[i] >= y[i];
00108                         return Result;
00109                 }
00110 
00113                 template <typename T, template <typename> class vecType> 
00114                 inline typename vecType<T>::bool_type equal
00115                 (
00116                         vecType<T> const & x, 
00117                         vecType<T> const & y
00118                 )
00119                 {
00120                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00121                                 "Invalid template instantiation of 'equal', GLM vector types required");
00122 
00123                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00124                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00125                                 Result[i] = x[i] == y[i];
00126                         return Result;
00127                 }
00128 
00131                 template <typename T, template <typename> class vecType> 
00132                 inline typename vecType<T>::bool_type notEqual
00133                 (
00134                         vecType<T> const & x, 
00135                         vecType<T> const & y
00136                 )
00137                 {
00138                         GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00139                                 "Invalid template instantiation of 'notEqual', GLM vector types required");
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                         GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00153                                 "Invalid template instantiation of 'any', GLM boolean vector types required");
00154 
00155                         bool Result = false;
00156                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00157                                 Result = Result || v[i];
00158                         return Result;
00159                 }
00160 
00163                 template <template <typename> class vecType> 
00164                 inline bool all(vecType<bool> const & v)
00165                 {
00166                         GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00167                                 "Invalid template instantiation of 'all', GLM boolean vector types required");
00168 
00169                         bool Result = true;
00170                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00171                                 Result = Result && v[i];
00172                         return Result;
00173                 }
00174 
00177                 template <template <typename> class vecType> 
00178                 inline vecType<bool> not_(vecType<bool> const & v)
00179                 {
00180                         GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00181                                 "Invalid template instantiation of 'not_', GLM vector types required");
00182 
00183                         typename vecType<bool>::bool_type Result(vecType<bool>::null);
00184                         for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00185                                 Result[i] = !v[i];
00186                         return Result;
00187                 }
00188 
00190 
00191         }//namespace vector_relational
00192         }//namespace function
00193         }//namespace core
00194 
00195         using namespace core::function::vector_relational;
00196 }//namespace glm
00197 
00198 #include "func_vector_relational.inl"
00199 
00200 #endif//glm_core_func_vector_relational