00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef freecloth_base_baMath_h
00020 #define freecloth_base_baMath_h
00021
00022 #ifndef freecloth_base_package_h
00023 #include <freecloth/base/package.h>
00024 #endif
00025
00026 #ifndef freecloth_base_types_h
00027 #include <freecloth/base/types.h>
00028 #endif
00029
00030 #ifndef freecloth_base_math_h
00031 #include <freecloth/base/math.h>
00032 #endif
00033
00034 #ifndef M_PI
00035 #define M_PI 3.14159f
00036 #endif
00037
00038 FREECLOTH_NAMESPACE_START
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class BaMath
00051 {
00052 public:
00053
00054
00055 static const Float TOLERANCE;
00056
00057
00058
00059 static Float ceil( Float );
00060 static Float floor( Float );
00061 static Float round( Float );
00062
00063
00064
00065
00066 static Int8 ceilInt8( Float );
00067 static Int8 floorInt8( Float );
00068 static Int8 roundInt8( Float );
00069 static UInt8 ceilUInt8( Float );
00070 static UInt8 floorUInt8( Float );
00071 static UInt8 roundUInt8( Float );
00072
00073 static Int16 ceilInt16( Float );
00074 static Int16 floorInt16( Float );
00075 static Int16 roundInt16( Float );
00076 static UInt16 ceilUInt16( Float );
00077 static UInt16 floorUInt16( Float );
00078 static UInt16 roundUInt16( Float );
00079
00080 static Int32 ceilInt32( Float );
00081 static Int32 floorInt32( Float );
00082 static Int32 roundInt32( Float );
00083 static UInt32 ceilUInt32( Float );
00084 static UInt32 floorUInt32( Float );
00085 static UInt32 roundUInt32( Float );
00086
00087
00088
00089 static Int8 roundTruncInt8( Float );
00090
00091 static UInt8 roundTruncUInt8( Float );
00092
00093 static Int16 roundTruncInt16( Float );
00094
00095 static UInt16 roundTruncUInt16( Float );
00096
00097 static Float abs( Float );
00098
00099
00100 static bool isInteger( Float );
00101
00102 static bool isPow2( UInt32 );
00103
00104 static UInt32 roundUpPow2( UInt32 );
00105
00106 static Float sqr( Float );
00107 static Float sqrt( Float );
00108
00109 static Float cos( Float );
00110 static Float sin( Float );
00111 static Float tan( Float );
00112 static Float arccos( Float );
00113 static Float arcsin( Float );
00114 static Float arctan( Float );
00115 static Float arctan2( Float y, Float x );
00116 static Float sinc( Float );
00117
00118 static Float exp( Float );
00119 static Float log( Float );
00120
00121
00122
00123 static UInt32 randomUInt32();
00124
00125
00126 static UInt32 randomUInt32( UInt32 nbVals );
00127
00128
00129
00130 static Float randomFloat();
00131
00132
00133
00134
00135 static bool isEqual( Float a, Float b, Float tol = TOLERANCE );
00136 static bool isGreater( Float a, Float b, Float tol = TOLERANCE );
00137 static bool isLess( Float a, Float b, Float tol = TOLERANCE );
00138
00139 };
00140
00141 FREECLOTH_NAMESPACE_END
00142
00143 #include <freecloth/base/baMath.inline.h>
00144
00145 #endif