diff options
author | mwturvey <michael.w.turvey@intel.com> | 2017-03-17 14:41:59 -0700 |
---|---|---|
committer | mwturvey <michael.w.turvey@intel.com> | 2017-03-17 14:41:59 -0700 |
commit | b6981854dff11022e3de56e56cbf4633f1c49598 (patch) | |
tree | f5b8f4ff1425f704d791d5b9af9c8af65455868d /redist/linmath.c | |
parent | 94be8ccdbfb2f44c9bc569428537444030ba8eeb (diff) | |
parent | a53c520c2d1a3bb9faa4cb5e4ee9ccc48bb1835f (diff) | |
download | libsurvive-b6981854dff11022e3de56e56cbf4633f1c49598.tar.gz libsurvive-b6981854dff11022e3de56e56cbf4633f1c49598.tar.bz2 |
Merge branch 'master' into UsbTrackerOnWin
# Conflicts:
# src/survive_vive.c
Diffstat (limited to 'redist/linmath.c')
-rw-r--r-- | redist/linmath.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/redist/linmath.c b/redist/linmath.c index dd6bd15..eefcd5f 100644 --- a/redist/linmath.c +++ b/redist/linmath.c @@ -207,28 +207,28 @@ void quattomatrix(FLT * matrix44, const FLT * qin) void quatfrommatrix( FLT * q, const FLT * matrix44 ) { //Algorithm from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ - float tr = matrix44[0] + matrix44[5] + matrix44[10]; + FLT tr = matrix44[0] + matrix44[5] + matrix44[10]; if (tr > 0) { - float S = sqrt(tr+1.0) * 2; // S=4*qw - q[0] = 0.25 * S; + FLT S = FLT_SQRT(tr+1.0) * 2.; // S=4*qw + q[0] = 0.25f * S; q[1] = (matrix44[9] - matrix44[6]) / S; q[2] = (matrix44[2] - matrix44[8]) / S; q[3] = (matrix44[4] - matrix44[1]) / S; } else if ((matrix44[0] > matrix44[5])&(matrix44[0] > matrix44[10])) { - float S = sqrt(1.0 + matrix44[0] - matrix44[5] - matrix44[10]) * 2; // S=4*qx + FLT S = FLT_SQRT(1.0 + matrix44[0] - matrix44[5] - matrix44[10]) * 2.; // S=4*qx q[0] = (matrix44[9] - matrix44[6]) / S; - q[1] = 0.25 * S; + q[1] = 0.25f * S; q[2] = (matrix44[1] + matrix44[4]) / S; q[3] = (matrix44[2] + matrix44[8]) / S; } else if (matrix44[5] > matrix44[10]) { - float S = sqrt(1.0 + matrix44[5] - matrix44[0] - matrix44[10]) * 2; // S=4*qy + FLT S = FLT_SQRT(1.0 + matrix44[5] - matrix44[0] - matrix44[10]) * 2.; // S=4*qy q[0] = (matrix44[2] - matrix44[8]) / S; q[1] = (matrix44[1] + matrix44[4]) / S; - q[2] = 0.25 * S; + q[2] = 0.25f * S; q[3] = (matrix44[6] + matrix44[9]) / S; } else { - float S = sqrt(1.0 + matrix44[10] - matrix44[0] - matrix44[5]) * 2; // S=4*qz + FLT S = FLT_SQRT(1.0 + matrix44[10] - matrix44[0] - matrix44[5]) * 2.; // S=4*qz q[0] = (matrix44[4] - matrix44[1]) / S; q[1] = (matrix44[2] + matrix44[8]) / S; q[2] = (matrix44[6] + matrix44[9]) / S; |