You cant rotate vector by simple quaternion multiplication. To get proper results you have to use the following formula:
v' = qvq<sup>-1</sup>
where q is quaternion containig rotation, v is a vector to be rotated represented as a quaternion with zero real (scalar) part, and q<sup>-1</sup> is the inverse of q. If q is normalised then its inverse is equal to conjugate of q.
This is my function for rotating vectors using quaternions.
Code:
function quatRotateVector(v : TVector; q : TQuatermion) : TVector;
var
q_1,qv,qt : TQuatermion;
begin
q := quatNormalize(q);
q_1 := quatConjugate(q);
qv := Quatermion(v,0.0);
qt := quatMul(q,qv);
qt := quatMul(qt,q_1);
Result.x := qt.x;
Result.y := qt.y;
Result.z := qt.z;
end;
I hope it helps you.
P. S. My code is not tested since I don't use quatrnion based camera.
Bookmarks