Last active
August 29, 2015 14:06
-
-
Save DomNomNom/e66b05ae098228431e46 to your computer and use it in GitHub Desktop.
Rotation identity
This file contains hidden or 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
// why does makeTransform1 give the same results as makeTransform2? | |
mat3 rotationMatrix(float angle, vec3 axis) { | |
... // returns a 3x3 rotation matrix for rotating about the given axis | |
} | |
mat3 makeTransform1(float alpha, float beta, float gamma) { | |
mat3 alphaTransform = rotationMatrix(alpha, vec3(0.0, 1.0, 0.0)); | |
mat3 betaTransform = rotationMatrix(beta, vec3(1.0, 0.0, 0.0)); | |
mat3 gammaTransform = rotationMatrix(gamma, vec3(0.0, 1.0, 0.0)); | |
return alphaTransform * betaTransform * gammaTransform; | |
} | |
mat3 makeTransform2(float alpha, float beta, float gamma) { | |
mat3 alphaTransform = rotationMatrix(alpha, vec3(0.0, 1.0, 0.0)); | |
mat3 betaTransform = rotationMatrix(beta, alphaTransform * vec3(1.0, 0.0, 0.0)); | |
mat3 gammaTransform = rotationMatrix(gamma, betaTransform * alphaTransform * vec3(0.0, 1.0, 0.0)); | |
return gammaTransform * betaTransform * alphaTransform; // NOTE: reversed order | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment