Mouse gestures can be interpreted according to needs of your application.

If you know the orientation of lookAt vector at the time gesture starts (V1), and you know its orientation after gesture (V2), then you should rotate around vectorV = V1 x V2, and the angle isang = arccos((V1.V2)/|V1.V2|), where x is vector product, . - scalar (dot) product, || - norma (length).

With quaternions, ifqcia a quaternion that represents orientation of the camera, andqris a quaternion that represents desired rotation, then

qc = qc * qr

The problem is to define quaternion that represents rotation. If you know theaxisaround which you want to rotate and theangle, then:

Code :void Quaternion::fromAxis(const vec &axis, double angle) { double sinAngle; angle *= 0.5; vect vn(v); vn.normalize(); sinAngle = sin(angle); x = (vn.x * sinAngle); y = (vn.y * sinAngle); z = (vn.z * sinAngle); w = cos(angle); }