Hi. I am using quaternions to do vector rotation. For some reason it is not working properly. When I try to rotate the vector 0,0,1 90 degrees along the x axis with this quaternion-0.70710678, 0, 0, 0.70710678(with the last number being w) the output is 0, -1,
-0.207107 which should be 0,-1,0. Here is my code for the vector rotation function.
What am I doing wrong?Code:ScePspFVector3 multvector(float quaternion[4], ScePspFVector3 vector) { float vectorQuaternion[4],resultQuaternion[4]; ScePspFVector3 resultVector; vectorQuaternion[0] = vector.x; vectorQuaternion[1] = vector.y; vectorQuaternion[2] = vector.z; vectorQuaternion[3] = 0.0f; float inverseQuaternion[4] = {-quaternion[0],-quaternion[1],-quaternion[2],quaternion[3]}; mult(resultQuaternion,quaternion, vectorQuaternion); mult(resultQuaternion,resultQuaternion, inverseQuaternion); resultVector.x = resultQuaternion[0]; resultVector.y = resultQuaternion[1]; resultVector.z = resultQuaternion[2]; return resultVector; }



LinkBack URL
About LinkBacks



