diff --git a/vcg/math/base.h b/vcg/math/base.h index e1c2a389..97d991e7 100644 --- a/vcg/math/base.h +++ b/vcg/math/base.h @@ -24,9 +24,6 @@ History $Log: not supported by cvs2svn $ -Revision 1.8 2004/03/08 19:40:48 tarini -*** empty log message *** - Revision 1.7 2004/03/08 19:38:29 tarini aggiunti Min e Max, si usano cosi: Min::Value (tarini) @@ -39,9 +36,6 @@ added Acos e Asin Revision 1.4 2004/03/03 22:51:49 cignoni changed math from class to template -Revision 1.3 2004/02/19 15:28:01 ponchio -*** empty log message *** - Revision 1.2 2004/02/13 02:18:57 cignoni Edited Comments and GPL license @@ -77,6 +71,7 @@ namespace math { inline float Sin(const float v) { return sinf(v); } inline float Acos(const float v) { return acosf(v); } inline float Asin(const float v) { return asinf(v); } + inline float Atan2(const float v0,const float v1) { return atan2f(v0,v1); } inline double Sqrt(const double v) { return sqrt(v); } inline double Abs(const double v) { return fabs(v); } @@ -84,43 +79,57 @@ namespace math { inline double Sin(const double v) { return sin(v); } inline double Acos(const double v) { return acos(v); } inline double Asin(const double v) { return asin(v); } + inline double Atan2(const double v0,const double v1) { return atan2(v0,v1); } /// max and min values for each scala type /// syntax: Max::Value - template class Min { - public: static const SCALAR Value; + template class Value { + public: static const SCALAR Min; static const SCALAR Min; }; - template class Max { - public: static const SCALAR Value; + + const char Value::Min = -128; + const char Value::Max = +127; + const unsigned char Value::Min = 0; + const unsigned char Value::Max = 255; + const short Value::Min = (-32767 -1); + const short Value::Max = +32767; + const unsigned short Value::Min = 0; + const unsigned short Value::Max = 65535; + const int Value::Min = (-2147483647 - 1); + const int Value::Max = +2147483647; + const unsigned int Value::Min = 0; + const unsigned int Value::Max = 4294967295; + const __int64 Value<__int64 >::Min = (-9223372036854775807i64 - 1); + const __int64 Value<__int64 >::Max = +9223372036854775807i64; + const long Value::Min = (-2147483647L -1L); + const long Value::Max = 2147483647L; + const unsigned long Value::Min = 0; + const unsigned long Value::Max = +4294967295; + const float Value::Min = -3.4E38F; + const float Value::Max = +3.4E38F; + const long double Value::Min = -1.2E308; //E4931? + const long double Value::Max = +1.2E308; + const double Value::Min = -1.7E308; + const double Value::Max = +1.7E308; + + inline template Min(const T &a, const T &b){ + if (a Max(const T &a, const T &b){ + if (a Swap(T &a, T &b){ + T tmp=a; a=b; b=tmp; + }; + inline template Sort(T &a, T &b){ + if (a>b) Swap(a,b); + }; + inline template Sort(T &a, T &b, T &c){ + if (a>b) Swap(a,b); + if (b>c) {Swap(b,c); if (a>b) Swap(a,b);} }; - - const char Min::Value = -128; - const char Max::Value = +127; - const unsigned char Min::Value = 0; - const unsigned char Max::Value = 255; - const short Min::Value = (-32767 -1); - const short Max::Value = +32767; - const unsigned short Min::Value = 0; - const unsigned short Max::Value = 65535; - const int Min::Value = (-2147483647 - 1); - const int Max::Value = +2147483647; - const unsigned int Min::Value = 0; - const unsigned int Max::Value = 4294967295; - const __int64 Min<__int64 >::Value = (-9223372036854775807i64 - 1); - const __int64 Max<__int64 >::Value = +9223372036854775807i64; - const long Min::Value = (-2147483647L -1L); - const long Max::Value = 2147483647L; - const unsigned long Min::Value = 0; - const unsigned long Max::Value = +4294967295; - const float Min::Value = -3.4E38F; - const float Max::Value = +3.4E38F; - const long double Min::Value = -1.2E308; //E4931? - const long double Max::Value = +1.2E308; - const double Min::Value = -1.7E308; - const double Max::Value = +1.7E308; - /* Some files do not define M_PI... */ #ifndef M_PI