WARNING: important change. Removed the useless vcg::math::Max(a,b) that mimicked the std::max, and changed into a three argument Max(a,b,c) (quite useful in a lot of context and missing in std::.

This commit is contained in:
Paolo Cignoni 2010-09-21 22:00:39 +00:00
parent 7977e270c5
commit 47138fce2f
1 changed files with 17 additions and 5 deletions

View File

@ -138,12 +138,24 @@ namespace math {
template <typename T> inline static T Sqr(T a) { return a*a; }
template<class T> inline const T & Min(const T &a, const T &b){
if (a<b) return a; else return b;
}
template<class T> inline const T & Max(const T &a, const T &b){
if (a<b) return b; else return a;
template<class T> inline const T & Min(const T &a, const T &b,const T &c){
if (a<b) {
if(a<c) return a;
else return c;
} else {
if(b<c) return b;
else return c;
}
}
template<class T> inline const T & Max(const T &a, const T &b, const T &c){
if (a>b) {
if(a>c) return a;
else return c; // if c<a then c is smaller than b...
} else {
if(b>c) return b;
else return c;
}
}
template<class T> inline void Swap(T &a, T &b){
T tmp=a; a=b; b=tmp;