From ed506a2ea5541a687192a7435025c78aefff6f6d Mon Sep 17 00:00:00 2001 From: mtarini Date: Mon, 8 Mar 2004 19:38:29 +0000 Subject: [PATCH] first version (tarini) --- vcg/math/base.h | 57 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/vcg/math/base.h b/vcg/math/base.h index 555ac0ad..267ad1ad 100644 --- a/vcg/math/base.h +++ b/vcg/math/base.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.6 2004/03/08 14:49:37 ponchio +Aggiunti un po di inline davanti alle funzioni + Revision 1.5 2004/03/04 00:21:00 ponchio added Acos e Asin @@ -44,6 +47,7 @@ Edited Comments and GPL license #include #include +#include #ifdef __BORLANDC__ float sqrtf (float v) {return sqrt(v);} @@ -75,22 +79,43 @@ namespace math { inline double Acos(const double v) { return acos(v); } inline double Asin(const double v) { return asin(v); } - - - template - class MaxVal - { - public: - //const unsigned char Math::MaxVal = 255; - //const char Math::MaxVal = 127; - //const unsigned short Math::MaxVal = 0xFFFFu; - //const short Math::MaxVal = 0x7FFF; - //const float Math::MaxVal = 3.4E38F; - //const int Math::MaxVal = 2147483647; - //const long double Math::MaxVal = 1.2E308; - //const double Math::MaxVal = 1.7E308; - //const __int64 Math<__int64 >::MaxVal = 9223372036854775807; - }; + + // max and min values for each scala type + // syntax: Max::Value + + template class Min { + public: static const SCALAR Value; + }; + template class Max { + public: static const SCALAR Value; + }; + + 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 #define M_PI 3.14159265358979323846