long stick behaviour in the air

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
archee
Posts: 4
Joined: Tue Nov 12, 2013 6:22 pm

long stick behaviour in the air

Post by archee »

I'm actually asking for help in making my own physics engine.
Some physics engines conserve the angular velocity of an object spinning in the air with no friction. I don't know if bullet does this.
However, according to physics books the angular momentum needs to be conserved.

To convert between angular velocity and angular momentum you need the inertia tensor. In case of a sphere or cube, this will be only-diagonal, with the same number, making the angular velocity always parallel to the angular momentum, and constant.

However, in case of a long piece of stick, the tensor is more distorted such as this:
50, 0, 0,
0, 0.1, 0,
0 , 0, 50
In this case the angular velocity and the angular momentum can be far from parallel.
Converting the preserved angular momentum to angular velocity in every frame (120HZ) can do the trick for less thin sticks, but due to the quantization it rotates off the track, resulting in changing it's kinetic energy, and strange speedups.

I also modelled the same thing using wireframe physics, connecting dots with springs/dampers to simulate a long stick. In this test the angular velocity wasn't preserved, but the kinetic energy and the angular momentum was, and it looked right.

My question is simple, how to rotate long objects properly?
archee
Posts: 4
Joined: Tue Nov 12, 2013 6:22 pm

Re: long stick behaviour in the air

Post by archee »

I found some explanation here, but unfortunately I can't understand it.
Anybody can explain to me in a simple way?

http://farside.ph.utexas.edu/teaching/3 ... ode61.html
RandyGaul
Posts: 43
Joined: Mon May 20, 2013 8:01 am
Location: Redmond, WA

Re: long stick behaviour in the air

Post by RandyGaul »

What integration are you using. If you're using forward Euler then the problem you are describing is a result of poor tangent line approximations of the equation of motion you're trying to satisfy.

In other words, you need to use a different integration scheme in order to get more accurate predictions of future state. You can try semi-implicit (simplectic) Euler. If this does not seem to suit your needs I would recommend trying Runge Kutta. However I would note that I have yet to have problems with simplectic Euler.
archee
Posts: 4
Joined: Tue Nov 12, 2013 6:22 pm

Re: long stick behaviour in the air

Post by archee »

I use a simple quantized method (I think, this is called Euler integration)

angularMomentum = worldTensor * angularVelocity;
translation.rotate(angularVelocity*timeStep);
updateWorldTensor();
angularVelocity = worldTensor.inverse() * angularMomentum;

Using smaller timeStep makes it more stable. The rotational Kinetic energy increases slowly and than heavily as the angular velocity approaches the minimum inertia axis.
As the engine is for gaming only, it would even solve the problem, if the energy was decreasing (as it would turn away from the minimum inertia axis)
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: long stick behaviour in the air

Post by bone »

http://math.ucsd.edu/~sbuss/ResearchWeb ... 11Talk.pdf

That might help if you need more accurate methods. Sam Buss has an older paper somewhere if you want more explanation.
archee
Posts: 4
Joined: Tue Nov 12, 2013 6:22 pm

Re: long stick behaviour in the air

Post by archee »

Thanks guys, these helped me to find a solution. (and I also released a patch for the old Tricky Truck with good rotations)
Post Reply