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 #ifndef WFMATH_CONST_H
00027 #define WFMATH_CONST_H
00028
00029 #include <cfloat>
00030
00031 #ifdef _MSC_VER
00032 #if _MSC_VER < 1300
00033 #error "You are using an older version of MSVC++ with extremely poor"
00034 #error "template support. Please use at least version 7.0, where the"
00035 #error "template support is merely bad, or try a different compiler."
00036 #else
00037
00038
00039
00040 #define WFMATH_NO_CLASS_FUNCTION_SPECIALIZATION 1
00041
00042 #define WFMATH_NO_TEMPLATES_AS_TEMPLATE_PARAMETERS 1
00043 #endif
00044 #endif
00045
00047 namespace WFMath {
00048
00049
00050
00051
00052 class AtlasInType;
00053 class AtlasOutType;
00054
00055 template<const int dim> class AxisBox;
00056 template<const int dim> class Ball;
00057 template<const int dim> class Point;
00058 template<const int dim> class Polygon;
00059 template<const int dim> class RotBox;
00060 template<const int dim> class RotMatrix;
00061 template<const int dim> class Segment;
00062 template<const int dim> class Vector;
00063 class Quaternion;
00064
00065
00066
00068 const double Pi = 3.14159265358979323846264338327950288419716939937508;
00070 const double SqrtPi = 1.77245385090551602729816748334114518279754945612237;
00072 const double LogPi = 1.14472988584940017414342735135305871164729481291530;
00074 const double Sqrt2 = 1.41421356237309504880168872420969807856967187537693;
00076 const double Sqrt3 = 1.73205080756887729352744634150587236694280525381037;
00078 const double Log2 = 0.69314718055994530941723212145817656807550013436025;
00079
00081 #define WFMATH_PRECISION_FUDGE_FACTOR 30
00082
00083 #define WFMATH_MAX_NORM_AGE ((WFMATH_PRECISION_FUDGE_FACTOR * 2) / 3)
00084
00086 typedef float CoordType;
00088 #define WFMATH_EPSILON (WFMATH_PRECISION_FUDGE_FACTOR * FLT_EPSILON)
00089
00091 #define WFMATH_MAX FLT_MAX
00092
00093 #define WFMATH_MIN FLT_MIN
00094
00095
00096
00097 double _ScaleEpsilon(double x1, double x2, double epsilon);
00098 double _ScaleEpsilon(const CoordType* x1, const CoordType* x2,
00099 int length, double epsilon = WFMATH_EPSILON);
00100
00102
00109 template<class C>
00110 inline bool Equal(const C& c1, const C& c2, double epsilon = WFMATH_EPSILON)
00111 {return c1.isEqualTo(c2, epsilon);}
00112
00113 bool Equal(double x1, double x2, double epsilon = WFMATH_EPSILON);
00114
00115 bool Equal(float x1, float x2, double epsilon = WFMATH_EPSILON);
00116
00117
00118
00119
00120 inline CoordType FloatMax(CoordType a, CoordType b)
00121 {return (a > b) ? a : b;}
00122 inline CoordType FloatMin(CoordType a, CoordType b)
00123 {return (a < b) ? a : b;}
00124 inline CoordType FloatClamp(CoordType val, CoordType min, CoordType max)
00125 {return (min >= val) ? min : (max <= val ? max : val);}
00126
00127 }
00128
00129 #endif // WFMATH_CONST_H