# LitDev Collision Physics Example

• ### Question

• LitDev,

Trying to figure out how your collision physics example works. I was wondering if you would be willing to provide a listing of what each of the variables is doing? Maybe even an explanation of how that program works. It's a great program to learn from. I understand some of it, but the balls flying around, I just don't have a clue. Especially when they run into each other.

Thanks,

JR

Wednesday, February 15, 2017 12:58 AM

• It's been a while since I did that and may do it differently now.  It was a bit over complex really, if I remember finding an itersection of the paths of balls, then doing a momentum balance with restitution.

I would start with fully elastic collisions calculating all in centre of mass frame - I think there are posts on this.  It will be easier to start writing your own.  First read up on the physics:

Many, this looks OK

http://www.real-world-physics-problems.com/physics-of-billiards.html

• Marked as answer by Wednesday, February 15, 2017 8:11 PM
Wednesday, February 15, 2017 6:53 PM

### All replies

• It's been a while since I did that and may do it differently now.  It was a bit over complex really, if I remember finding an itersection of the paths of balls, then doing a momentum balance with restitution.

I would start with fully elastic collisions calculating all in centre of mass frame - I think there are posts on this.  It will be easier to start writing your own.  First read up on the physics:

Many, this looks OK

http://www.real-world-physics-problems.com/physics-of-billiards.html

• Marked as answer by Wednesday, February 15, 2017 8:11 PM
Wednesday, February 15, 2017 6:53 PM
• Thank you for the article. I will study it. I do think your collision program is simply amazing. I have a hard time just getting 1 ball to float across the screen. For you to do it with 15 or more has shown me that it can be done.

Thanks,

JR

• Marked as answer by Wednesday, February 15, 2017 8:10 PM
• Unmarked as answer by Wednesday, February 15, 2017 8:11 PM
Wednesday, February 15, 2017 8:10 PM
• Have a go with the physics then try 2 balls - keep it simple with them just bouncing off the walls, then start doing their collision - I will help.

The steps will be:

1] detect collision (overlap or centres within diameter of each other)

2] transform velocities to centre of mass frame

3] do a collision - reflect velocities

4] restore from CM frame to their moving frame

Step 3 is like this, smae for ball B and C, easiest if balls are the same size (and mass).

• Edited by Wednesday, February 15, 2017 8:40 PM
Wednesday, February 15, 2017 8:40 PM
• Thanks for helping. I'm going to start with your reference article first and then come back to this. What does item 4 mean. I don't know what CM stands for.

JR

Wednesday, February 15, 2017 9:14 PM
• Just revert from CM velocities to true velocities after collision calcs.

Here is a simple example of this, try with just 2 balls if you like - the only complication is to make sure the balls are fully separated after a collision, HQG621.

Wednesday, February 15, 2017 10:00 PM
•  I don't know what CM stands for.

JR

Center of Mass

Jan [ WhTurner ] The Netherlands

Thursday, February 16, 2017 10:22 AM
• @WhTurner33 - thanks for clearing that up - I misread JR's post

@JR - modified program - QTT745

Just the same CM bounce physics as before - just updated with optimisation tinkerings to improve internal bounce handling, settling of balls with gravity, friction and elasticity, and some simple keyboard (Space, Q, A, Z) and mouse click action.  The LD extension bits are just graphical gradient effects - easily removed.

Friday, February 17, 2017 7:35 PM
• WHTurner33 and LitDev,

Thanks to both of you for helping. Have been reading about center of mass from KhanAcademy.org which has some good information on it's site. I do understand some of the program code, but not all. When I've learned enough to ask questions I'll start asking. The new program helps.

Thanks,

JR

Friday, February 17, 2017 9:52 PM
• Hi guys !

Here is a program i did many months ago, to experiment Ldphysics and gravity.

Program no : DWC797

In this one, i used moon gravity.

LDPhysics.SetGravity (1,16) ' moon gravity 100/6 = 16,6

you will see marbles of different sizes, 50 of them, falling from the top of the screen , to the floor, and then bouncing until it stops.

Friday, February 17, 2017 10:34 PM