Roll Stabilized Camera w/Quaternion

I want to roll stabilize my quaternion based scene navigation camera class. In order to do this I need a quaternion operation that will set the rotation about one axis to zero while preserving the rotations about the second two axes. All I have so far is to get the euler angles from the quaternion then rebuild the quaternion from the euler angles with the appropriate angle set to zero. Seems like a lot of calculations for this operation to me. Anyone have any good ideas for a quicker method?

Thanks,
Paul

No Ideas?

Originally posted by pleopard:
No Ideas?
We want to formulate a rotation about the front direction that turns our roll into given_roll.

In order to do this, we perform a Gram-Schmidt normalization step of the up axis with respect to the rotated front direction. The angle between this vector and the rotated up direction is our current roll. All that remains is to construct the quaternion

exp(0,(given_roll-roll)*(rotated_front)/2)

most thing quaternions are good for (soft blending of abitrary 3d-orientations) can be done with direct construct of the transform out of three base-vectors.
The idea is to create three control-vectors, and then made them a base (hence a transform) by orthonormalization, as last post stated.
the nice thing is that most work is already implemented in gluLookAt(): you can feed it with three abitrary vectors which are then automatically orthonormalized to a transform.

to blend motion, just get actual local “forward” and “up” vectors of your cam, then bend them slightly toward you wanted locations and feed them to gluLookAt.
i’m not sure if this paradigm is capable of reconstruct the same motions quaternions would do, but for a start, its quite fine i think.

Just an idea, I’m not sure if that’s the most efficient way of implementing it:

You could transform the y (up) vector with the quaternion. This gives you an error vector that should be pointing up. Take the cross product and dot product of the up vector and the error vector, thats the axis and angle you’ll have to rotate backwards to correct the error (conviniently in the format that’s required for constructing a quaternion out of it :wink: )