Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bill2727

Rotation of asymmetrical bodies in rigid body simulator switch and halt periodically

This topic is 5677 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I thought I finally pinned rotation down for my primitive little physics engine until I decided to try an asymetrical shape (a box with different side lengths) and all hell broke lose! The shape would rotate somewhat about the designated axis but its behavior was mind-boggling.. it would literally stop and start, and fidget around a bit, only to rotate in another direction. Of course I don''t expect anyone to know the specifics of my simulator.. but I don''t even know where to look! I improved my numerical integration in case some sort of numerical error got magnified, and I''ve checked and double checked inertia tensors for my objects. What else could it be? Could someone knowledgable in this domain at least tell me what to investigate? I''m puzzled because rotation for symmetrical bodies (cubes, spheres) works absolutely perfectly for any arbitrary axis. If you need any specifics I''ll gladly elaborate as much as needed.. thanks.

Share this post


Link to post
Share on other sites
Advertisement
Your description is not very clear but this sounds like it could be correct behaviour.

A non-symmetric body experiencing torque free rotation does not in general have a fixed axis of rotation. The details of this are too involved to go into but I will give a concrete example which demonstates this.

Take a hardback book and wrap an elastic band around it to keep it closed. Then try throwing it up in the air and spinning it about the three axes of symmetry of it''s bounding box.

What you should find is it''s easy to spin it around the shortest and longest axis but it will not spin about the intermediate axis (for a book this is the axis parallel to the lines of text on the pages). Instead it will tumble with it''s axis of rotation continuously changing, speeding up and slowing down as this happens to preserve it''s rotational kinetic energy.

This is normal behaviour and it arises from a correct implementation of the dynamics when the moment of inertia tensor is not a multiple of the identity matrix. It needs more careful coding to make sure it doesn''t blow up (e.g to make sure energy doesn''t increment for no reason) and is smooth, but if your seeing it something like this it just confirms your implementation is right.

For a detailed mathematical exploration of this see pages 205 - 213 of Goldstein''s "Classical Mechanics". I''ve seen similar information online but nothing to match that in Goldstein: try searching for "Torque Free" in a search engine.

Share this post


Link to post
Share on other sites
Thanks a lot for the reply. I do see what you''re saying.. and its corroborated by the fact that when rotated along its 3 principle axes, a box of any dimensions doesn''t exhibit the flaky behavior. However while the equations might not be grilled into my brain I do have an intuitive feel for how something rotatates.. objects in my simulator will literally rotate along a certain axis and then double back for a second on seemingly that same axis only to go forward again.. it just seems a little too chaotic and sudden for a rotating object, I always thought it would be more gradual.
Oh and that "blow up" comment couldn''t be more timely.. I just noticed with particularly long objects and/or high angular velocity they start speeding up at a faster and faster rate until they freak out the whole system.. what exactly would I constrain to stop that?
Anyway, thanks again, hopefully the problem is just my perception rather than the underlying coding.

Share this post


Link to post
Share on other sites
I''m really stumped anyone know why my physically modeled system wont obey conservation of energy? Why does a torque free object start gaining angular velocity faster and faster the longer its been spinning, and what do I constrain to fix it? I already constrain my rotation matrix (to make it orthogonal and unit lenth), so i really don''t know what to tweak!

Share this post


Link to post
Share on other sites
Bill,

What numerical integration technique are you using? Simple Euler? Runge-Kutta? Verlet? Except for the simplest of problems (baby textbook examples) and very special situations (the so-called "perfect shift" condition), all numerical methods exhibit truncation errors that can lead to energy gain or loss. The goal in physics simulation is to choose a method that is as close to possible to being conservative. A system such as yours, in which energy is created, is an unstable simulation. If you are using simple Euler, that''s no surprise. This method basically *requires* a little damping to obtain a stable simulation. Most any of the other techniques are going to work better than Euler, but the others may require damping as well for your situation.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
> ...it just seems a little too chaotic and sudden for a
> rotating object, I always thought it would be more gradual.

I really recommend you try it: you don''t need a book, just a closed CD case. Try spinning it quickly about the middle length axis (the one parallel to it''s spine/hinge) as you throw it up in the air 20-30cm and catch it. 99 times out of 100 it will be using a completely different axis after rotating through only a couple or three turns.

> Why does a torque free object start gaining angular velocity
> faster and faster the longer its been spinning, and what do I
> constrain to fix it?

One way to constrain it is: work out the rotational KE before and after, and if it''s increased scale the angular velocity by the reciprocal of the square root of the scale by which it''s increased. E.g. if the KE is increased by 10% scale the angular velocity by 1 / srqt (1.1). If you are also applying drag add it in seperately after applying this fix.

This only eliminates the extra energy, but it does not make the answer right in other ways. E.g. you may still see the axis drifting over time as other errors accumulate. The only fix to this is use a better integrator as Graham suggests and/or increase the update rate/decrease the step size.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!