diff options
author | Ferenc Arn <tagcup@yahoo.com> | 2017-01-14 14:35:39 -0600 |
---|---|---|
committer | Ferenc Arn <tagcup@yahoo.com> | 2017-01-16 13:36:33 -0600 |
commit | 6f4f9aa6ded6da027c84cc466c767334dc3d3362 (patch) | |
tree | 4d45d7e600a069d7feb2a2dae3a70d6b9ddbf884 /core/math/matrix3.cpp | |
parent | d13f2f9e25e380496e706b59720cd85eed299ca2 (diff) | |
download | redot-engine-6f4f9aa6ded6da027c84cc466c767334dc3d3362.tar.gz |
Overloaded basic math funcs (double and float variants). Use real_t rather than float or double in generic functions (core/math) whenever possible.
Also inlined some more math functions.
Diffstat (limited to 'core/math/matrix3.cpp')
-rw-r--r-- | core/math/matrix3.cpp | 20 |
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 |