Advertisement

Creating rolling sphere in OpenGL

Started by October 14, 1999 12:29 AM
2 comments, last by drstrangeluv 25 years, 1 month ago
I can't answer your question fully, but I just wanted to let you know that yes it is possible. It would involve several rotations around different axes at different times. Now HOW to do this, I can't help you with at the moment. But at least you know that it's possible. :-)

Kevin

Admin for GameDev.net.

I'm trying to accurately simulate a rolling sphere in OpenGL; however, the physics text I have access to only covers rotation for objects with fixed axis. The problem is that, while I can get the sphere to roll, once it comes to a stop and I want it to roll in a different direction, I can't seem to get around rotating the sphere. Is it possible to simulate a rolling object without fixed axis in OpenGL and, if so, how?
Advertisement
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.

Do you have any source code for the following usage of quaternions?


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.






This topic is closed to new replies.

Advertisement