Kochol Game Engine  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
math.h
Go to the documentation of this file.
1 // File name: math.h
2 // Des: Dar in file tamame tabe haye riyazi gharar migire.
3 // Date: 30/8/1385
4 // Programmer: Ali Akbar Mohammadi(Kochol)
5 
6 #ifndef KGE_MATH_H
7 #define KGE_MATH_H
8 
9 namespace kge
10 {
12 namespace math
13 {
14  class Sphere;
15  class Vector;
16  class Plane;
17 
20  {
22  ECT_In ,
28  }; // Collision type
29 
31  const float PI = 3.141592654f;
32  const float TwoPI = 6.283185307f;
33  const float PiOver2 = 1.570796326f;
34 
35  const float fDegToRad = 0.0174532925f;
36  const float fRadToDeg = 57.295779513f;
37 
38  const float fEpsilon = 0.000001f;
39 
41 
45  inline float DegToRad(float Degree)
46  {
47  return (Degree * fDegToRad);
48 
49  } // DegToRad
50 
51 
53 
57  inline float RadToDeg(float Radian)
58  {
59  return (Radian / PI * 180);
60 
61  } // RadToDeg
62 
63  inline float abs(float Number)
64  {
65  if ( Number < 0 ) return -Number;
66 
67  return Number;
68 
69  } // abs
70 
72  inline int pow(int x, int y)
73  {
74  //if (y == 0)
75  // return 1;
76  //return pow(x, y - 1) * x;
77  int result = 1;
78  for (; y > 0; --y)
79  result *= x;
80  return result;
81 
82  } // pow
83 
84  // max - float
85  inline float Max(float A,float B)
86  {
87  return (A>=B) ? A : B;
88  }
89 
90 
91  // min - float
92  inline float Min(float A,float B)
93  {
94  return (A<=B) ? A : B;
95  }
96 
97 
99  bool SweptSpherePlaneIntersect(float& t0, float& t1,
100  const Plane& plane, const Sphere& sphere, const Vector& sweepDir);
101 
102 } // math
103 
104 } // kge
105 
106 #endif // KGE_MATH_H