Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ikr7/8a67196667189ad8904e to your computer and use it in GitHub Desktop.
Save ikr7/8a67196667189ad8904e to your computer and use it in GitHub Desktop.
XYZ で回すのをクォータニオンにするやつ.js
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