NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

JDK1.0.2 simulations (1996-2001) => kinematics => Topic started by: pleasedontgocrazy on August 31, 2005, 11:25:43 pm



Title: Q:Bouncing Balls (Masses): two ball collide with each other
Post by: pleasedontgocrazy on August 31, 2005, 11:25:43 pm
If I know to balls and there velocities and the masses how do i find there final velocities. So far I have assumed that the two balls have the same mass but this may not be true in some cases.

Here is the code for a collision so far
   
    'Ball A
   
    NewAngle = WorkOutRADAngle(Ball(BallA), Ball(BallB))
       
    NewSpeed(BallA).X = BallSpeed(BallB) * -Cos(NewAngle - BallAngle(BallB))
    NewSpeed(BallA).Y = BallSpeed(BallA) * Sin(NewAngle - BallAngle(BallA))
       
    MoveBall(BallA).X = (NewSpeed(BallA).Y * Sin(NewAngle)) - (NewSpeed(BallA).X * Cos(NewAngle))
    MoveBall(BallA).Y = (NewSpeed(BallA).Y * -Cos(NewAngle)) - (NewSpeed(BallA).X * Sin(NewAngle))
       
    'Ball B
       
    NewAngle = WorkOutRADAngle(Ball(BallB), Ball(BallA))
       
    NewSpeed(BallB).X = BallSpeed(BallA) * -Cos(NewAngle - BallAngle(BallA))
    NewSpeed(BallB).Y = BallSpeed(BallB) * Sin(NewAngle - BallAngle(BallB))
       
    MoveBall(BallB).X = (NewSpeed(BallB).Y * Sin(NewAngle)) - (NewSpeed(BallB).X * Cos(NewAngle))
    MoveBall(BallB).Y = (NewSpeed(BallB).Y * -Cos(NewAngle)) - (NewSpeed(BallB).X * Sin(NewAngle))

What happens when the balls have differnt masses?

Here the program so far: http://www.freewebs.com/dave_fooks/BounceBalls.exe

P.s. Moveball is the new velocity for the ball


Title: topic268
Post by: Fu-Kwun Hwang on September 02, 2005, 07:04:52 am
Please check out  2D collision (http://www.phy.ntnu.edu.tw/ntnujava/viewtopic.php?t=19)