summaryrefslogtreecommitdiffstats
path: root/core/math/matrix3.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-01-20 19:24:49 -0300
committerGitHub <noreply@github.com>2017-01-20 19:24:49 -0300
commitee0f53df52d88ca57079579f3f3e943e7e40f53a (patch)
treefcf670f1e8aec411c6deaf97e9fc77bf5c195f31 /core/math/matrix3.cpp
parent72a02555850016ab792cf498c5370983d3b72832 (diff)
parent6f4f9aa6ded6da027c84cc466c767334dc3d3362 (diff)
downloadredot-engine-ee0f53df52d88ca57079579f3f3e943e7e40f53a.tar.gz
Merge pull request #7528 from tagcup/real_t_float_fixes
Use real_t rather than float or double in generic functions (core/mat…
Diffstat (limited to 'core/math/matrix3.cpp')
-rw-r--r--core/math/matrix3.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index e9c3442582..1fabfbbd4c 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -504,9 +504,9 @@ void Basis::get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const {
ERR_FAIL_COND(is_rotation() == false);
- double angle,x,y,z; // variables for result
- double epsilon = 0.01; // margin to allow for rounding errors
- double epsilon2 = 0.1; // margin to distinguish between 0 and 180 degrees
+ real_t angle,x,y,z; // variables for result
+ real_t epsilon = 0.01; // margin to allow for rounding errors
+ real_t epsilon2 = 0.1; // margin to distinguish between 0 and 180 degrees
if ( (Math::abs(elements[1][0]-elements[0][1])< epsilon)
&& (Math::abs(elements[2][0]-elements[0][2])< epsilon)
@@ -525,12 +525,12 @@ void Basis::get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const {
}
// otherwise this singularity is angle = 180
angle = Math_PI;
- double xx = (elements[0][0]+1)/2;
- double yy = (elements[1][1]+1)/2;
- double zz = (elements[2][2]+1)/2;
- double xy = (elements[1][0]+elements[0][1])/4;
- double xz = (elements[2][0]+elements[0][2])/4;
- double yz = (elements[2][1]+elements[1][2])/4;
+ real_t xx = (elements[0][0]+1)/2;
+ real_t yy = (elements[1][1]+1)/2;
+ real_t zz = (elements[2][2]+1)/2;
+ real_t xy = (elements[1][0]+elements[0][1])/4;
+ real_t xz = (elements[2][0]+elements[0][2])/4;
+ real_t yz = (elements[2][1]+elements[1][2])/4;
if ((xx > yy) && (xx > zz)) { // elements[0][0] is the largest diagonal term
if (xx< epsilon) {
x = 0;
@@ -567,7 +567,7 @@ void Basis::get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const {
return;
}
// as we have reached here there are no singularities so we can handle normally
- double s = Math::sqrt((elements[1][2] - elements[2][1])*(elements[1][2] - elements[2][1])
+ real_t s = Math::sqrt((elements[1][2] - elements[2][1])*(elements[1][2] - elements[2][1])
+(elements[2][0] - elements[0][2])*(elements[2][0] - elements[0][2])
+(elements[0][1] - elements[1][0])*(elements[0][1] - elements[1][0])); // s=|axis||sin(angle)|, used to normalise