How to simulate an elastic collision?

What did you draw?
Post Reply
ahmedkq
Posts: 9
Joined: Sat Feb 15, 2014 5:59 am

How to simulate an elastic collision?

Post by ahmedkq » Sun Oct 31, 2021 2:20 pm

I tried to simulate a collision between two bodies with nograv options. I thought I would get an elastic collision result, but it seems that the collision is not perfectly elastic!

Code: Select all

//Gravity fun at TestTubeGames
_settings(gravity: 0.000001*r^(-2));
_add(m: 1, col: 4, lcol: 4, pic: 1, x: -200, y: 0, vx: 5, t: 0,nograv);
_add(m: 1, col: 2, lcol: 2, pic: 1, x: 0, y: 0, t: 0,nograv);
In the above code, the left body was moving with 5 m/s, then it hits another similar body but in rest. If the collision is elastic, the moving body should stop completely, and the body in rest should move by 5 m/s after the collision. This does not happen. Instead, the right body went by 3.75 m/s, and the left body's speed decreased to 1.25 m/s. This means that the total kinetic energy has been decreased from 12.5 J to 7.8125 J.

Is there any option to make the collision elastic?

Thank you so much for your attention and participation.

User avatar
testtubegames
Site Admin
Posts: 1088
Joined: Mon Nov 19, 2012 7:54 pm

Re: How to simulate an elastic collision?

Post by testtubegames » Tue Nov 16, 2021 2:58 pm

Oh, there's a setting that will help you out here. There's a Coefficient of Restitution that you can set in the Planets Menu in the lower right. By default it's set to .5 -- but you can set it to 1 for a perfectly elastic collision.

Post Reply