Kevin
Creating rolling sphere in OpenGL
Admin for GameDev.net.
Store the rotation of the sphere as a quaternion O. For each time slice, take the rotational velocity vector w and perform the following calculation:
w' = O*w*O^-1;
O*= quaternion( cos( len(w')/2 ), sin( len(w')/2 )* unit(w') );
where quaternion(s,v) generates a quaternion w/ a real s part and imaginary v, len(v) calculates the magnitude of v, and you have multiplication and inversion operators for quaternions define.
Now, just use O to rotate the sphere into the proper position and orientation.
quote:
Original post by msn12b
The simple answer? Assuming you are using quaternions, its relatively trivial.Store the rotation of the sphere as a quaternion O. For each time slice, take the rotational velocity vector w and perform the following calculation:
w'' = O*w*O^-1;
O*= quaternion( cos( len(w'')/2 ), sin( len(w'')/2 )* unit(w'') );where quaternion(s,v) generates a quaternion w/ a real s part and imaginary v, len(v) calculates the magnitude of v, and you have multiplication and inversion operators for quaternions define.
Now, just use O to rotate the sphere into the proper position and orientation.