00001 #pragma once
00002
00003 #include <time.h>
00004 #include <stdlib.h>
00005 #include <math.h>
00006 #include "defines.h"
00007
00008
00009 #define ZAK_PI 3.1415926535897932384626433832795
00010 #define DegreeToRad(n) n*0.017453292519943295769236907684886
00011 #define RadToDegree(n) n*57.295779513082320876798154814105
00012 #define ZAK_MAX_RAND 180000
00013
00014 namespace zak {
00015
00022 class ZAKENGINE_API MathUtil {
00023
00024 public:
00030 static float ATan(float tan);
00031
00037 static float ACos(float cos);
00038
00044 static float ASin(float sin);
00045
00051 static float Sin(float degree);
00052
00058 static float Cos(float degree);
00059
00065 static float Tan(float degree);
00066
00073 static void SinCos(float degree, float *sine, float *cosine);
00074
00090 static int Random() {
00091 _randIndex++;
00092
00093 if (_randIndex >= ZAK_MAX_RAND) {
00094 _randIndex = 0;
00095 }
00096
00097 return _rand[_randIndex];
00098 }
00099
00108 static float DistanceQuad (float x1, float y1, float x2, float y2) { return ((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); }
00109
00118 static float Distance (float x1, float y1, float x2, float y2) { return sqrt(((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))); }
00119
00125 static float Round (float num);
00126
00127 private:
00128 static bool Initialize();
00129 static void Shutdown() {
00130 if (_rand)
00131 delete [] _rand;
00132 }
00133
00134 static void SinCosCalc(float degree, float *sine, float *cosine);
00135 static float _sin[360];
00136 static float _cos[360];
00137 static float _tan[360];
00138 static int *_rand;
00139 static int _randIndex;
00140
00141 friend class Game;
00142 };
00143
00144 };