PDA

View Full Version : Rotation Vectors



AndrewJJ
06-01-2002, 12:00 AM
Hi,

I'm looking for advice / solution to a fairly minor problem that my tired
brain can't figure out. I need to rotate an object from a rotational vector
(xs, ys, zs) to a target vector of (xd, yd, zd) in incremental steps to
achieve animated rotation. My initial solution was simply to subtract one
vector from the other and divide the result by a factor that determined the
number of rotational increments. Now all worked but I noticed that there
were occasions when an object would rotate through a larger angle than was
needed.

If you consider an object with an x rotation of 270 and you want it to
rotate to 0 then my result requests a rotation of -270 whereas 90 degrees
would have been the quicker move ! I'm looking for a general solution that
provides me with the minimum solution and copes with all angles i.e. -90 is
the same as 270 as is -180 and 180 ...

(I can't believe that I can't get my head around this one ... especially
after deriving a Quaternion based camera class !)


I look forward to hearing from you ...

Many thanks

Andrew

dorbie
06-01-2002, 12:27 AM
The axis of rotation should be the cross product of the two vectors. The rotation ammount should be the arccossine of the dot product of the two vectors divided by the number of iterrations. You may have to negate the rotation angle or an input vector.