diff options
author | Mike Turvey <mturvey6@gmail.com> | 2017-05-21 16:13:33 -0700 |
---|---|---|
committer | Mike Turvey <mturvey6@gmail.com> | 2017-05-21 16:13:33 -0700 |
commit | d71cc918dd2905a74e9ff0b7168433078d598e48 (patch) | |
tree | c2e103792c1267008cfe97cfb6d7c924e8b22203 /redist | |
parent | 956460db5cc0adca08e3db29c0fec09e51fd04e4 (diff) | |
download | libsurvive-d71cc918dd2905a74e9ff0b7168433078d598e48.tar.gz libsurvive-d71cc918dd2905a74e9ff0b7168433078d598e48.tar.bz2 |
Fix Tori Poser
quattomatrix33() needed to be updated after the fix in quatfrom2vectors
Additional poser updates to make it more robust.
Poser is now updating based on both lighthouses. Expect significant jitter from this.
Diffstat (limited to 'redist')
-rw-r--r-- | redist/linmath.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/redist/linmath.c b/redist/linmath.c index 5fefe1e..b3896ff 100644 --- a/redist/linmath.c +++ b/redist/linmath.c @@ -259,35 +259,37 @@ void quatfrommatrix( FLT * q, const FLT * matrix44 ) } +// Algorithm from http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/ void quattomatrix33(FLT * matrix33, const FLT * qin) { FLT q[4]; quatnormalize(q, qin); //Reduced calulation for speed - FLT xx = 2 * q[0] * q[0]; - FLT xy = 2 * q[0] * q[1]; - FLT xz = 2 * q[0] * q[2]; - FLT xw = 2 * q[0] * q[3]; + FLT xx = 2 * q[1] * q[1]; + FLT xy = 2 * q[1] * q[2]; + FLT xz = 2 * q[1] * q[3]; + FLT xw = 2 * q[1] * q[0]; + + FLT yy = 2 * q[2] * q[2]; + FLT yz = 2 * q[2] * q[3]; + FLT yw = 2 * q[2] * q[0]; - FLT yy = 2 * q[1] * q[1]; - FLT yz = 2 * q[1] * q[2]; - FLT yw = 2 * q[1] * q[3]; + FLT zz = 2 * q[3] * q[3]; + FLT zw = 2 * q[3] * q[0]; - FLT zz = 2 * q[2] * q[2]; - FLT zw = 2 * q[2] * q[3]; //opengl major matrix33[0] = 1 - yy - zz; - matrix33[1] = xy - zw; - matrix33[2] = xz + yw; + matrix33[1] = xy + zw; + matrix33[2] = xz - yw; - matrix33[3] = xy + zw; + matrix33[3] = xy - zw; matrix33[4] = 1 - xx - zz; - matrix33[5] = yz - xw; + matrix33[5] = yz + xw; - matrix33[6] = xz - yw; - matrix33[7] = yz + xw; + matrix33[6] = xz + yw; + matrix33[7] = yz - xw; matrix33[8] = 1 - xx - yy; } |