【发布时间】:2015-04-07 03:02:22
【问题描述】:
我一直在开发一个基本的游戏引擎来学习这个过程,但我的旋转功能遇到了问题。
它工作正常,只是对象缩小并看起来倒置。
这里有一个jsfiddle 来说明我的观点。
我认为问题在于轮换代码本身,但我并不积极。
function Rotation(vec, rot){
if(Math.acos((vec.x + vec.y + vec.z -1)/2) === 0) { return vec; }
var qVec = new Quaternion(vec.x, vec.y, vec.z, 0);
qVec = Quaternions.multiply(qVec, rot);
qVec = Quaternions.multiply(qVec, rot.conjugate());
return new Vector3(qVec.x, qVec.y, qVec.z);
}
【问题讨论】:
标签: javascript vector rotation game-engine quaternions