2D deflection

Posts: 2
Joined: 2009.01
Post: #1
I am talking about sphere on sphere deflection, I have x1, y1, x2, y2 (positions for each sphere), I have r1, r2 (radius for each) and vx1, vy1, vx2, vy2 (x and y velocities of each) and m1, m2 (masses for each)

First I check to see if they intersect (r1+r2 > distance_between), but I cant seem to wrap my head around how to deflect them with each other. They are hitting each other at some angle, which I could get from the slope of the line between them, no problem, but could someone write some psuedo-code for this kind of deflection, I cant seem to get it. Thanks in advance, Will.
Quote this message in a reply
Posts: 469
Joined: 2002.10
Post: #2
First back up the spheres until they are non-intersecting or close to. Then draw a line between the centers. Dot with each sphere's velocity vector to find the force component you need to sum and reflect. Update your velocity vectors and the move by the time you backed up.

I did all this math a long time ago but I don't have any code to show for it. Sorry. There are simpler/faster/less accurate ways of doing things, so don't take my word for it.

15.4" MacBook Pro revA
Quote this message in a reply
Post Reply