func_vector_relational.hpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 #ifndef glm_core_func_vector_relational
00030 #define glm_core_func_vector_relational
00031 
00032 #include "_detail.hpp"
00033 
00034 namespace glm
00035 {
00038 
00043     template <typename T, template <typename> class vecType> 
00044         GLM_FUNC_QUALIFIER typename vecType<T>::bool_type lessThan
00045         (
00046                 vecType<T> const & x, 
00047                 vecType<T> const & y
00048         )
00049         {
00050                 GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00051                         "Invalid template instantiation of 'lessThan', GLM vector types required");
00052                 GLM_STATIC_ASSERT(detail::is_bool<T>::_NO,
00053                         "Invalid template instantiation of 'lessThan', GLM vector types required floating-point or integer value types vectors");
00054 
00055                 typename vecType<bool>::bool_type Result(vecType<bool>::null);
00056                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00057                         Result[i] = x[i] < y[i];
00058 
00059                 return Result;
00060         }
00061 
00066         template <typename T, template <typename> class vecType> 
00067         GLM_FUNC_QUALIFIER typename vecType<T>::bool_type lessThanEqual
00068         (
00069                 vecType<T> const & x, 
00070                 vecType<T> const & y
00071         )
00072         {
00073                 GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00074                         "Invalid template instantiation of 'lessThanEqual', GLM vector types required");
00075                 GLM_STATIC_ASSERT(detail::is_bool<T>::_NO, 
00076                         "Invalid template instantiation of 'lessThanEqual', GLM vector types required floating-point or integer value types vectors");
00077 
00078                 typename vecType<bool>::bool_type Result(vecType<bool>::null);
00079                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00080                         Result[i] = x[i] <= y[i];
00081                 return Result;
00082         }
00083 
00088         template <typename T, template <typename> class vecType> 
00089         GLM_FUNC_QUALIFIER typename vecType<T>::bool_type greaterThan
00090         (
00091                 vecType<T> const & x, 
00092                 vecType<T> const & y
00093         )
00094         {
00095                 GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00096                         "Invalid template instantiation of 'greaterThan', GLM vector types required");
00097                 GLM_STATIC_ASSERT(detail::is_bool<T>::_NO, 
00098                         "Invalid template instantiation of 'greaterThan', GLM vector types required floating-point or integer value types vectors");
00099 
00100                 typename vecType<bool>::bool_type Result(vecType<bool>::null);
00101                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00102                         Result[i] = x[i] > y[i];
00103                 return Result;
00104         }
00105 
00110         template <typename T, template <typename> class vecType> 
00111         GLM_FUNC_QUALIFIER typename vecType<T>::bool_type greaterThanEqual
00112         (
00113                 vecType<T> const & x, 
00114                 vecType<T> const & y
00115         )
00116         {
00117                 GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00118                         "Invalid template instantiation of 'greaterThanEqual', GLM vector types required");
00119                 GLM_STATIC_ASSERT(detail::is_bool<T>::_NO, 
00120                         "Invalid template instantiation of 'greaterThanEqual', GLM vector types required floating-point or integer value types vectors");
00121 
00122                 typename vecType<bool>::bool_type Result(vecType<bool>::null);
00123                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00124                         Result[i] = x[i] >= y[i];
00125                 return Result;
00126         }
00127 
00132         template <typename T, template <typename> class vecType> 
00133         GLM_FUNC_QUALIFIER typename vecType<T>::bool_type equal
00134         (
00135                 vecType<T> const & x, 
00136                 vecType<T> const & y
00137         )
00138         {
00139                 GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00140                         "Invalid template instantiation of 'equal', GLM vector types required");
00141 
00142                 typename vecType<bool>::bool_type Result(vecType<bool>::null);
00143                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00144                         Result[i] = x[i] == y[i];
00145                 return Result;
00146         }
00147 
00152         template <typename T, template <typename> class vecType> 
00153         GLM_FUNC_QUALIFIER typename vecType<T>::bool_type notEqual
00154         (
00155                 vecType<T> const & x, 
00156                 vecType<T> const & y
00157         )
00158         {
00159                 GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, 
00160                         "Invalid template instantiation of 'notEqual', GLM vector types required");
00161 
00162                 typename vecType<bool>::bool_type Result(vecType<bool>::null);
00163                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00164                         Result[i] = x[i] != y[i];
00165                 return Result;
00166         }
00167 
00172         template <template <typename> class vecType> 
00173         GLM_FUNC_QUALIFIER bool any(vecType<bool> const & v)
00174         {
00175                 GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00176                         "Invalid template instantiation of 'any', GLM boolean vector types required");
00177 
00178                 bool Result = false;
00179                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00180                         Result = Result || v[i];
00181                 return Result;
00182         }
00183 
00188         template <template <typename> class vecType> 
00189         GLM_FUNC_QUALIFIER bool all(vecType<bool> const & v)
00190         {
00191                 GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00192                         "Invalid template instantiation of 'all', GLM boolean vector types required");
00193 
00194                 bool Result = true;
00195                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00196                         Result = Result && v[i];
00197                 return Result;
00198         }
00199 
00205         template <template <typename> class vecType> 
00206         GLM_FUNC_QUALIFIER vecType<bool> not_(vecType<bool> const & v)
00207         {
00208                 GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, 
00209                         "Invalid template instantiation of 'not_', GLM vector types required");
00210 
00211                 typename vecType<bool>::bool_type Result(vecType<bool>::null);
00212                 for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
00213                         Result[i] = !v[i];
00214                 return Result;
00215         }
00216 
00218 }//namespace glm
00219 
00220 #include "func_vector_relational.inl"
00221 
00222 #endif//glm_core_func_vector_relational