Created
September 12, 2016 09:21
-
-
Save Justinfront/64ee6938510caa61a30d7c7997b57414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function turn (X, Y) { | |
// for the math, see http://www.texpaste.com/n/ev3443eo | |
var | |
X2 = X*X, Y2 = Y*Y, | |
q = 1 + X2 + Y2, | |
s = 1 - X2 - Y2, | |
r2 = 1/(q*q), s2 = s*s, | |
A = (s2 + 4*(Y2 - X2))*r2, B = -8*X*Y*r2, C = 4*s*X*r2, | |
D = (s2 + 4*(X2 - Y2))*r2, E = 4*s*Y*r2, | |
F = (s2 - 4*(X2 + Y2))*r2; | |
mat4.multiply(mo_matrix, [ | |
A, B, C, 0, | |
B, D, E, 0, | |
-C, -E, F, 0, | |
0, 0, 0, 1 | |
], | |
mo_matrix); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment