Skip to content

Instantly share code, notes, and snippets.

@edom18
Created July 17, 2013 23:45
Show Gist options
  • Save edom18/6025576 to your computer and use it in GitHub Desktop.
Save edom18/6025576 to your computer and use it in GitHub Desktop.
クォータニオン(四元数)のメモ ref: http://qiita.com/edo_m18/items/5cbedcea95fef82161b2
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