Created
July 17, 2013 23:45
-
-
Save edom18/6025576 to your computer and use it in GitHub Desktop.
クォータニオン(四元数)のメモ ref: http://qiita.com/edo_m18/items/5cbedcea95fef82161b2
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 makeQuaternion(radian, vector) { | |
var ret = new Quaternion(), | |
ccc = 0, | |
sss = 0, | |
axis = new Vector3(vector.toArray()), | |
norm = vector.norm(); | |
if (norm <= 0.0) { | |
return ret; | |
} | |
axis.normalize(); | |
//cos(θ/2) | |
ccc = cos(0.5 * radian); | |
//sin(θ/2) | |
sss = sin(0.5 * radian); | |
var t = ccc; //実部 | |
axis.multiplyScalar(sss); //虚部 | |
//計算した値をQuaternionにセット | |
ret.set(t, axis); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment