Browse Source

MatMath only one way of rad deg conversion

Thomas Buck 11 years ago
parent
commit
780646bad7
5 changed files with 11 additions and 53 deletions
  1. 4
    0
      ChangeLog
  2. 0
    22
      include/MatMath.h
  3. 5
    5
      src/Camera.cpp
  4. 0
    24
      src/MatMath.cpp
  5. 2
    2
      src/OpenRaider.cpp

+ 4
- 0
ChangeLog View File

5
 
5
 
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7
 
7
 
8
+	[ 20140111 ]
9
+	* Only one way of conversion between Deg and Rad in MatMath
10
+	* Use the same style of include guards in all headers
11
+
8
 	[ 20140110 ]
12
 	[ 20140110 ]
9
 	* Removed endian.(h/cpp) as it shouldn't be needed. See:
13
 	* Removed endian.(h/cpp) as it shouldn't be needed. See:
10
 	  http://commandcenter.blogspot.de/2012/04/byte-order-fallacy.html
14
 	  http://commandcenter.blogspot.de/2012/04/byte-order-fallacy.html

+ 0
- 22
include/MatMath.h View File

104
  ------------------------------------------------------*/
104
  ------------------------------------------------------*/
105
 
105
 
106
 
106
 
107
-vec_t helDegToRad(vec_t degrees);
108
-/*------------------------------------------------------
109
- * Pre  : Given angle in degrees
110
- * Post : Returns angle in radians
111
- *
112
- *-- History ------------------------------------------
113
- *
114
- * 1999.06.14:
115
- * Mongoose - Created, from mtk3d
116
- ------------------------------------------------------*/
117
-
118
-vec_t helRadToDeg(vec_t rad);
119
-/*------------------------------------------------------
120
- * Pre  : Given angle in radians
121
- * Post : Returns angle in degrees
122
- *
123
- *-- History ------------------------------------------
124
- *
125
- * 1999.06.14:
126
- * Mongoose - Created, from mtk3d
127
- ------------------------------------------------------*/
128
-
129
 vec_t helRandomNum(vec_t from, vec_t to);
107
 vec_t helRandomNum(vec_t from, vec_t to);
130
 
108
 
131
 #endif
109
 #endif

+ 5
- 5
src/Camera.cpp View File

55
 	mFlags = 0;
55
 	mFlags = 0;
56
 	mViewDistance = 14.0;
56
 	mViewDistance = 14.0;
57
 	mTranslateDelta = 256.0;
57
 	mTranslateDelta = 256.0;
58
-	mRotateDelta = helDegToRad(15.0);
59
- 	mRotateDelta2 = helDegToRad(5.0);
58
+	mRotateDelta = HEL_DEG_TO_RAD(15.0);
59
+ 	mRotateDelta2 = HEL_DEG_TO_RAD(5.0);
60
 	mFlags &= Camera_FlyMode;
60
 	mFlags &= Camera_FlyMode;
61
 	reset();
61
 	reset();
62
 }
62
 }
103
 
103
 
104
 float Camera::getYaw()
104
 float Camera::getYaw()
105
 {
105
 {
106
-	return helRadToDeg(mTheta);
106
+	return HEL_RAD_TO_DEG(mTheta);
107
 }
107
 }
108
 
108
 
109
 
109
 
231
 
231
 
232
 void Camera::setSensitivityY(float angle)
232
 void Camera::setSensitivityY(float angle)
233
 {
233
 {
234
-	mRotateDelta2 = helDegToRad(angle);
234
+	mRotateDelta2 = HEL_DEG_TO_RAD(angle);
235
 }
235
 }
236
 
236
 
237
 
237
 
238
 void Camera::setSensitivityX(float angle)
238
 void Camera::setSensitivityX(float angle)
239
 {
239
 {
240
-	mRotateDelta = helDegToRad(angle);
240
+	mRotateDelta = HEL_DEG_TO_RAD(angle);
241
 }
241
 }
242
 
242
 
243
 
243
 

+ 0
- 24
src/MatMath.cpp View File

7
 #include <Vector3d.h>
7
 #include <Vector3d.h>
8
 #include <Matrix.h>
8
 #include <Matrix.h>
9
 
9
 
10
-#define COMPUTE
11
-
12
 bool tmpHelSphereIntersectLine(Vector3d pos, Vector3d lastPos,
10
 bool tmpHelSphereIntersectLine(Vector3d pos, Vector3d lastPos,
13
 										 Vector3d center, vec_t radius)
11
 										 Vector3d center, vec_t radius)
14
 {
12
 {
290
 	return from + (to*rand()/(RAND_MAX+1.0));
288
 	return from + (to*rand()/(RAND_MAX+1.0));
291
 }
289
 }
292
 
290
 
293
-
294
-vec_t helDegToRad(vec_t degrees)
295
-{
296
-#ifdef COMPUTE
297
-	return ((degrees / 180.0) * HEL_PI);
298
-#else
299
-	// degrees * (180.0 / PI);
300
-	return (degrees * HEL_180_OVER_PI);
301
-#endif
302
-}
303
-
304
-
305
-vec_t helRadToDeg(vec_t rad)
306
-{
307
-#ifdef COMPUTE
308
-	return ((rad / HEL_PI) * 180.0);
309
-#else
310
-	// rad * (PI / 180.0);
311
-	return (rad * HEL_PI_OVER_180);
312
-#endif
313
-}
314
-

+ 2
- 2
src/OpenRaider.cpp View File

3296
 				print(true, "Room %2i  Pos %.0f %.0f %.0f  Yaw %.0f  Pitch %.0f",
3296
 				print(true, "Room %2i  Pos %.0f %.0f %.0f  Yaw %.0f  Pitch %.0f",
3297
 						LARA->room,
3297
 						LARA->room,
3298
 						LARA->pos[0], LARA->pos[1], LARA->pos[2],
3298
 						LARA->pos[0], LARA->pos[1], LARA->pos[2],
3299
-						helRadToDeg(LARA->angles[1]),
3300
-						helRadToDeg(LARA->angles[2]));
3299
+						HEL_RAD_TO_DEG(LARA->angles[1]),
3300
+						HEL_RAD_TO_DEG(LARA->angles[2]));
3301
 			}
3301
 			}
3302
 		}
3302
 		}
3303
 		else if (rc_command("room", cmd))
3303
 		else if (rc_command("room", cmd))

Loading…
Cancel
Save