Created
February 14, 2016 15:10
-
-
Save ikr7/8a67196667189ad8904e to your computer and use it in GitHub Desktop.
XYZ で回すのをクォータニオンにするやつ.js
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
const algebra = require('algebra'); | |
const xyz2q = function (thx, thy, thz) { | |
const x = new algebra.Quaternion([ | |
Math.cos(thx / 2), | |
Math.sin(thx / 2), | |
0, | |
0 | |
]); | |
const y = new algebra.Quaternion([ | |
Math.cos(thy / 2), | |
0, | |
Math.sin(thy / 2), | |
0 | |
]); | |
const z = new algebra.Quaternion([ | |
Math.cos(thz / 2), | |
0, | |
0, | |
Math.sin(thz / 2) | |
]); | |
return x.mul(y).mul(z).data; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment