2

I'm developing a pool game in java for andorid. I have problems trying to make the balls collide between them. All the balls have the same mass and radius. I know the position of each ball before they collide and their velocity (in x, y) and I need to know the velocity of each ball after the collision.

Can somebody give me an algorithm or a formula to calculate them?

kevings14
  • 1,986
  • 2
  • 18
  • 19
  • 1
    http://stackoverflow.com/questions/16152498/the-momentum-is-not-conserved-after-collision-resolution-between-balls – Isaac Aug 12 '13 at 14:11
  • I wonder if Google would have helped if asked the same question there... – ppeterka Aug 12 '13 at 14:59

2 Answers2

3

The answer actually belongs to Physics(Collision dynamics) rather than Computer Science.

There are mainly two types of collisions - elastic and inelastic. To simulate a real world scenario, you should implement the inelastic rules. However, they are more complex, and several variables are involved other than the particle mass and velocity. Therefore, you better start with elastic collisions.

Solution(Elastic) : Here two rules always hold - conservation of momentum and conservation of kinetic energy. Say u1,u2 are initial velocities of the balls having mass m1,m2 and their final velocities are V1,V2 :

m1u1 + m2u2 = m1V1 + m2V2

m1u12 + m2u22 = m1V12 + m2V22

Solve the above equation from the known values m1, u1, m2, u2 and you will get V1 and V2.

blackSmith
  • 3,054
  • 1
  • 20
  • 37
1

I used the following link for the circle collision algorithm in my game. Worked great for me. https://sites.google.com/site/t3hprogrammer/research/circle-circle-collision-tutorial

merfanzo
  • 33
  • 4