aboutsummaryrefslogtreecommitdiff
path: root/redist/linmath.c
diff options
context:
space:
mode:
authorMichael Turvey <mwturvey@users.noreply.github.com>2017-03-27 16:26:49 -0700
committerGitHub <noreply@github.com>2017-03-27 16:26:49 -0700
commit885debded48e5c6d6a28c3193e572d623f15750c (patch)
tree6d323f71926af9e1cb8e3f827ac5a613c77b97d0 /redist/linmath.c
parent01c05b1a4df2dd85d9cafb4290616ecfe21304f4 (diff)
parentd8c4b23789fd3aedb150144bed6beb286d1504a9 (diff)
downloadlibsurvive-885debded48e5c6d6a28c3193e572d623f15750c.tar.gz
libsurvive-885debded48e5c6d6a28c3193e572d623f15750c.tar.bz2
Merge pull request #45 from mwturvey/AddingPosers
Tori Tracking is getting VERY close
Diffstat (limited to 'redist/linmath.c')
-rw-r--r--redist/linmath.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/redist/linmath.c b/redist/linmath.c
index 1724a13..caff1de 100644
--- a/redist/linmath.c
+++ b/redist/linmath.c
@@ -82,6 +82,28 @@ FLT anglebetween3d( FLT * a, FLT * b )
return FLT_ACOS(dot);
}
+// algorithm found here: http://inside.mines.edu/fs_home/gmurray/ArbitraryAxisRotation/
+void rotatearoundaxis(FLT *outvec3, FLT *invec3, FLT *axis, FLT angle)
+{
+ // TODO: this really should be external.
+ normalize3d(axis, axis);
+
+ FLT s = FLT_SIN(angle);
+ FLT c = FLT_COS(angle);
+
+ FLT u=axis[0];
+ FLT v=axis[1];
+ FLT w=axis[2];
+
+ FLT x=invec3[0];
+ FLT y=invec3[1];
+ FLT z=invec3[2];
+
+ outvec3[0] = u*(u*x + v*y + w*z)*(1-c) + x*c + (-w*y + v*z)*s;
+ outvec3[1] = v*(u*x + v*y + w*z)*(1-c) + y*c + ( w*x - u*z)*s;
+ outvec3[2] = w*(u*x + v*y + w*z)*(1-c) + z*c + (-v*x + u*y)*s;
+}
+
/////////////////////////////////////QUATERNIONS//////////////////////////////////////////
//Originally from Mercury (Copyright (C) 2009 by Joshua Allen, Charles Lohr, Adam Lowman)
//Under the mit/X11 license.