Browse Source

Merge pull request #504 from HrishikeshP-01/better-use-of-Math

Replaced static math functions in CameraMatrix by Math usage
Marc 4 years ago
parent
commit
9598fd5c8e
2 changed files with 4 additions and 9 deletions
  1. 2 7
      include/core/CameraMatrix.hpp
  2. 2 2
      src/core/CameraMatrix.cpp

+ 2 - 7
include/core/CameraMatrix.hpp

@@ -5,6 +5,7 @@
 #include "Plane.hpp"
 #include "Rect2.hpp"
 #include "Transform.hpp"
+#include "Math.hpp"
 
 #include <vector>
 
@@ -39,15 +40,9 @@ struct CameraMatrix {
 
 	static real_t get_fovy(real_t p_fovx, real_t p_aspect) {
 
-		return rad2deg(atan(p_aspect * tan(deg2rad(p_fovx) * 0.5)) * 2.0);
+		return Math::rad2deg(atan(p_aspect * tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0);
 	}
 
-	static inline double deg2rad(double p_y) { return p_y * Math_PI / 180.0; }
-	static inline float deg2rad(float p_y) { return p_y * Math_PI / 180.0; }
-
-	static inline double rad2deg(double p_y) { return p_y * 180.0 / Math_PI; }
-	static inline float rad2deg(float p_y) { return p_y * 180.0 / Math_PI; }
-
 	static inline double absd(double g) {
 
 		union {

+ 2 - 2
src/core/CameraMatrix.cpp

@@ -585,7 +585,7 @@ real_t CameraMatrix::get_fov() const {
 	right_plane.normalize();
 
 	if ((matrix[8] == 0) && (matrix[9] == 0)) {
-		return rad2deg(acos(abs(right_plane.normal.x))) * 2.0;
+		return Math::rad2deg(acos(abs(right_plane.normal.x))) * 2.0;
 	} else {
 		// our frustum is asymmetrical need to calculate the left planes angle separately..
 		Plane left_plane = Plane(matrix[3] + matrix[0],
@@ -594,7 +594,7 @@ real_t CameraMatrix::get_fov() const {
 				matrix[15] + matrix[12]);
 		left_plane.normalize();
 
-		return rad2deg(acos(abs(left_plane.normal.x))) + rad2deg(acos(abs(right_plane.normal.x)));
+		return Math::rad2deg(acos(abs(left_plane.normal.x))) + Math::rad2deg(acos(abs(right_plane.normal.x)));
 	}
 }