ソースを参照

Using constants of math.h

Thomas Buck 10年前
コミット
4c47d3edbe
3個のファイルの変更7行の追加27行の削除
  1. 7
    6
      include/MatMath.h
  2. 0
    20
      src/Camera.cpp
  3. 0
    1
      test/MatMath.cpp

+ 7
- 6
include/MatMath.h ファイルの表示

6
  * \author Mongoose
6
  * \author Mongoose
7
  */
7
  */
8
 
8
 
9
+#include <math.h>
10
+
9
 #ifndef _MATMATH_H
11
 #ifndef _MATMATH_H
10
 #define _MATMATH_H
12
 #define _MATMATH_H
11
 
13
 
12
-#define HEL_PI           3.14159265358979323846 //!< pi
13
-#define HEL_PI_OVER_2    1.57079632679489661923 //!< pi/2
14
-#define HEL_2_PI         6.28318530717958647692 //!< pi*2
15
-#define HEL_PI_OVER_4    0.78539816339744830962 //!< pi/4
16
-#define HEL_PI_OVER_180  0.017453292519943295   //!< pi/180
17
-#define HEL_180_OVER_PI  57.295779513082323     //!< 180/pi
14
+#define HEL_PI           M_PI //!< pi
15
+#define HEL_2_PI         (M_PI * 2.0) //!< pi*2
16
+#define HEL_PI_OVER_4    M_PI_4 //!< pi/4
17
+#define HEL_PI_OVER_180  (M_PI / 180.0) //!< pi/180
18
+#define HEL_180_OVER_PI  (180.0 / M_PI) //!< 180/pi
18
 
19
 
19
 #define HEL_RAD_TO_DEG(x) ((x) * HEL_180_OVER_PI) //!< Convert radians to degrees
20
 #define HEL_RAD_TO_DEG(x) ((x) * HEL_180_OVER_PI) //!< Convert radians to degrees
20
 #define HEL_DEG_TO_RAD(x) ((x) * HEL_PI_OVER_180) //!< Convert degrees to radians
21
 #define HEL_DEG_TO_RAD(x) ((x) * HEL_PI_OVER_180) //!< Convert degrees to radians

+ 0
- 20
src/Camera.cpp ファイルの表示

265
 	  mPos[1] -= (mTranslateDelta * sin(mTheta2));
265
 	  mPos[1] -= (mTranslateDelta * sin(mTheta2));
266
 	  break;
266
 	  break;
267
   case CAMERA_MOVE_LEFT:
267
   case CAMERA_MOVE_LEFT:
268
-#ifdef OBSOLETE
269
-	  //mPos[0] -= (mTranslateDelta * sin(mTheta2+MTK_PI_OVER_4));
270
-	  mPos[1] -= (mTranslateDelta * cos(mTheta));
271
-
272
-	  if (mFlags & Camera_FlyMode)
273
-	  {
274
-		  mPos[2] -= (mTranslateDelta * cos(mTheta2+MTK_PI_OVER_4));
275
-	  }
276
-#else
277
 	  mPos[0] -= (mTranslateDelta * sin(mTheta - 90.0f));
268
 	  mPos[0] -= (mTranslateDelta * sin(mTheta - 90.0f));
278
 	  mPos[2] -= (mTranslateDelta * cos(mTheta - 90.0f));
269
 	  mPos[2] -= (mTranslateDelta * cos(mTheta - 90.0f));
279
-#endif
280
 	  break;
270
 	  break;
281
   case CAMERA_MOVE_RIGHT:
271
   case CAMERA_MOVE_RIGHT:
282
-#ifdef OBSOLETE  // I have no idea when it got out of hand
283
-	  //mPos[0] += (mTranslateDelta * sin(mTheta2+MTK_PI_OVER_4));
284
-	  mPos[1] += (mTranslateDelta * cos(mTheta));
285
-
286
-	  if (mFlags & Camera_FlyMode)
287
-	  {
288
-		  mPos[2] += (mTranslateDelta * cos(mTheta2+MTK_PI_OVER_4));
289
-	  }
290
-#else
291
 	  mPos[0] -= (mTranslateDelta * sin(mTheta + 90.0f));
272
 	  mPos[0] -= (mTranslateDelta * sin(mTheta + 90.0f));
292
 	  mPos[2] -= (mTranslateDelta * cos(mTheta + 90.0f));
273
 	  mPos[2] -= (mTranslateDelta * cos(mTheta + 90.0f));
293
-#endif
294
 	  break;
274
 	  break;
295
  case CAMERA_ROTATE_UP:
275
  case CAMERA_ROTATE_UP:
296
      if (mTheta2 < (M_PI / 2)) {
276
      if (mTheta2 < (M_PI / 2)) {

+ 0
- 1
test/MatMath.cpp ファイルの表示

21
 
21
 
22
 TEST constants() {
22
 TEST constants() {
23
     ASSERT_EQm("Pi not correct!", HEL_PI, M_PI);
23
     ASSERT_EQm("Pi not correct!", HEL_PI, M_PI);
24
-    ASSERT_EQm("Pi/2 not correct!", HEL_PI_OVER_2, (M_PI / 2.0));
25
     ASSERT_EQm("2Pi not correct!", HEL_2_PI, (M_PI * 2.0));
24
     ASSERT_EQm("2Pi not correct!", HEL_2_PI, (M_PI * 2.0));
26
     ASSERT_EQm("Pi/4 not correct!", HEL_PI_OVER_4, (M_PI / 4.0));
25
     ASSERT_EQm("Pi/4 not correct!", HEL_PI_OVER_4, (M_PI / 4.0));
27
     ASSERT_EQm("Pi/180 not correct!", HEL_PI_OVER_180, (M_PI / 180.0));
26
     ASSERT_EQm("Pi/180 not correct!", HEL_PI_OVER_180, (M_PI / 180.0));

読み込み中…
キャンセル
保存