I am writing a 3D rigid body simulation. I use a quaternion for the

orientation, but I use a "spin vector" for the angular velocity. The

direction of the spin vector (omega) is the spin axis and the magnitude is

the rate (radians per second). I think that this is a common practice.

When I step forward in time, for example using Euler integration, how do I

add the spin vector to the quaternion?

Given:

dt = duration of timestep

q = orientation of the rigid body (a quaternion)

omega = angular velocity of the body (a 3d vector)

How do I compute Euler integration:

q' = q + dt*omega

I have come up with four alternatives,

(1)

a. Convert q to a spin vector, s

b. compute r = s + dt*omega using vector arithmetic

c. q' = convert r back to a quaternion

(2)

a. convert dt*omega to a quaternion, q2.

b. use quaternion composition q' = q * q2.

(You can see definition of quaternion conversion and composition

at http://www.cs.berkeley.edu/~laura/cs184/quat/quaternion.html )

(3)

a. convert omega to a quaternion, q2.

b. q' = SLERP(dt from q to q2)

(4)

a. compute dq using the matrix...

|-x -y -z |

dq = 1/2 * | w -z y | * omega

| z w -x |

|-y x w |

b. compute q' = q + dt*dq using element-wise arithmetic,

i.e. ( q.w + dt*dq.w, q.x + dt*dq.x, ....)

c. normalize q' to the unit hypersphere

My opinion is that (1) is dead wrong, (2) and (3) might be equivalent and

are the most accurate, (4) is ok for very small dt*omega, but is bad as q

+ dt*dq leaves the surface of the hypersphere.

Any help or pointers are GREATLY APPRECIATED!!!

If you post a reply, please cc: my email address.