Advertisement

Mid-frame collission

Started by February 22, 2003 10:46 AM
2 comments, last by walkingcarcass 22 years ago
I have seen many articles on how two moving objects may pass through each other in between frames and not be detected. Their solutions are often along the lines of "generate several spheres to fill the gap and test those against each other". I don't like this. Say two spheres at positions Pa and Pb (at the begining of the frame) with radiuses Ra and Rb moving at velocities Va and Vb A=Pa+Va*time B=Pb+Vb*time at some time |A-B|=Ar+Br ((Pa-Pb)+(Va-Vb)*time)^2=(Ar+Br)^2 R=(Ar+Br)^2 F=(Pa-Pb) G=(Va-Vb) F.F + F.G*2*time + G.G = R The time the two spheres collide is (R - G.G - F.F)/(2*F.G) [edit] F.F + F.G*2*time + G.G*time^2 = R G.G*time^2 +F.G*2*time + F.F - R = 0 [/edit] Isn't this much more accurate and efficient? ******** A Problem Worthy of Attack Proves It's Worth by Fighting Back [edited by - walkingcarcass on February 23, 2003 7:29:08 AM]
spraff.net: don't laugh, I'm still just starting...
I don't know about accuracy. You lost a time^2 on G.G. At least as near as I can tell. Logically it isn't correct since there would be only one solution, but two spheres have two times at which they just touch if they pass through one another. So logically it should be a quadradic which implies you dropped a time^2.

Seperately what if your two spheres are moving along a spline? What if they are orbiting a point that is moving along a spline? In the simple case of the spheres moving in a straight line it is a good solution. Solving a quadradic is reasonable, a cubic gets less so and a quartic gets down right self-defeating. There is no general solution to higher order polynomials so you are left with numeric solutions which is the alternative you mentioned. Overall people can generally grasp a numeric solution more readily with a limited math background particularly where you have complex motion. Even with an extensive math background some fairly simple problems can become complex to solve. So it is basically a tool in the toolbox worth having.

[edited by - LilBudyWizer on February 22, 2003 1:24:28 PM]
Keys to success: Ability, ambition and opportunity.
Advertisement
I read an interesting simple solution to collide with 2 moving spheres, I implemented it in my engine and it work #1.

the principe is, if you substract the amount of move of a sphere, and add it to the other sphere, you got the relative movement of a sphere from the other one.

Now, add the radius of the moving sphere to the static one.

check if the movement vector of the moving sphere (only the line) intersect with the big static sphere.

If the ray collide with the big sphere, this is the exact point of collision.

To get the exact time of collision, get the ratio of the travel of the ball and the total distance. then multiply the frame time by the ratio.

I know is not the best explanation of the world, but the principe is there.

I lost the address where I found this algorithm, but I know this is on gamasutra.

Fantasio.

Oops, yeah, there is a mistake!

F.F + F.G*2*time + G.G*time^2 = R

G.G*time^2 +F.G*2*time + F.F - R = 0

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...

This topic is closed to new replies.

Advertisement