Math.h
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
00027
00028 #ifndef ROCKETCOREMATH_H
00029 #define ROCKETCOREMATH_H
00030
00031 #include <Rocket/Core/Header.h>
00032
00033 namespace Rocket {
00034 namespace Core {
00035 namespace Math {
00036
00037
00038 extern ROCKETCORE_API const float PI_BY_TWO;
00039
00040 extern ROCKETCORE_API const float PI;
00041
00042 extern ROCKETCORE_API const float TWO_PI_BY_THREE;
00043
00044 extern ROCKETCORE_API const float TWO_PI;
00045
00046
00047 template < typename Type >
00048 Type Max(Type a, Type b)
00049 {
00050 return (a > b) ? a : b;
00051 }
00052
00053 template< typename Type >
00054 Type Min(Type a, Type b)
00055 {
00056 return (a < b) ? a : b;
00057 }
00058
00059 template < typename Type >
00060 Type ClampLower(Type value, Type min)
00061 {
00062 return (value < min) ? min : value;
00063 }
00064
00065 template < typename Type >
00066 Type ClampUpper(Type value, Type max)
00067 {
00068 return (value > max) ? max: value;
00069 }
00070
00071 template< typename Type >
00072 Type Clamp(Type value, Type min, Type max)
00073 {
00074 return (value < min) ? min : (value > max) ? max : value;
00075 }
00076
00080 ROCKETCORE_API bool IsZero(float value);
00086 ROCKETCORE_API bool AreEqual(float value_0, float value_1);
00087
00091 ROCKETCORE_API float AbsoluteValue(float value);
00092
00096 ROCKETCORE_API float Cos(float angle);
00100 ROCKETCORE_API float ACos(float value);
00104 ROCKETCORE_API float Sin(float angle);
00108 ROCKETCORE_API float ASin(float angle);
00112 ROCKETCORE_API float Tan(float angle);
00117 ROCKETCORE_API float ATan2(float y, float x);
00118
00122 ROCKETCORE_API float RadiansToDegrees(float angle);
00126 ROCKETCORE_API float DegreesToRadians(float angle);
00130 ROCKETCORE_API float NormaliseAngle(float angle);
00131
00135 ROCKETCORE_API float SquareRoot(float value);
00136
00140 ROCKETCORE_API int Round(float value);
00144 ROCKETCORE_API int RoundUp(float value);
00148 ROCKETCORE_API int RoundDown(float value);
00149
00153 ROCKETCORE_API int RealToInteger(float value);
00154
00158 ROCKETCORE_API int ToPowerOfTwo(int value);
00159
00163 ROCKETCORE_API int HexToDecimal(char hex_digit);
00164
00168 ROCKETCORE_API float RandomReal(float max_value);
00172 ROCKETCORE_API int RandomInteger(int max_value);
00175 ROCKETCORE_API bool RandomBool();
00176
00177 }
00178 }
00179 }
00180
00181 #endif