2D Static-Dynamic Circle Collision

Started by
4 comments, last by Verminox 17 years, 7 months ago
Ok so I read quite a few articles on 2D Collision Detection, and I am able to make the following collisions work correctly: 1. Moving Rect - Moving Rect 2. Moving Rect - Static Rect 3. Moving Disc - Static Rect (Ball-Wall Collision) 4. Moving Disc - Moving Disc (Ball-Ball Collision) Now I'm faced with another type of collision which, might seem easy to most, but I'm having a hard time figuring out: 5. Moving Disc - Static Disc I'm trying to implement this for an Air Hockey game, where the user hits the puck with the striker. Now, if I use the conservation of momentum method I end up with the striker moving backward after the collision, which I don't want happening. Of course, this is because in the real world the human player would supply external force to keep the striker from moving after a collision but then that would make the conservation of momentum not applicable. How would I go about doing this? PS: I tried a very poor method by using the same method as in 2 moving discs, where the striker had a huge mass as compared to the puck, but that made the puck go at rocket speeds after each collision. Very poor indeed :(
--------------------------------------Amaze your friends! Astound your family! Kennify your text!
Advertisement
MovingDisc - StaticDisk is exactly the same as MovingDisk - MovingDisk. Where is the problem? If you have moving vs moving, then the static test should be just the same, but with a velocity set to (0, 0).

EDIT : Oh, I get it. YOu problems seems to be related to physics, not collisions itself.

EDIT AGAIN! : ok, you can still use the conservation of momentum. YOu can set the coefficient restitution of the puck and the player to be very low in your equations, that should make the puck stick a bit more. But in the end, you will have to bodge it, so the puck stays stuck to the player.

Everything is better with Metal.

No you are not getting my problem here. I am able to detect the collisions, it is only a problem while calculating the rebound.

I don't want it to be like the pool table scenario because if I do that then the striker (mallet) which is user controled will also rebound in the opposite direction after a head on collision. I don't want the striker to be moved after the collision, just the puck.

Think of what I want to do similar to the classic PONG game with the parallel running paddles and the ball moving around the screen. Now imagine the paddles could be moved forward/backward also rather than just sideways... now what will be the resultant effect on the magnitude of the velocity of the ball after the bounce? It should obviously increase after collision, but by how much? The reason we cannot apply the basic conservation of momentum here is because that will also give us a a change in velocity of the paddle, which we dont want. And in terms of direction, my game has a "circular" paddle (i.e the mallet/striker) so it is not just a disc-rect collision, so I will also need to know by what angle the ball rebounds/deviates after collision.
--------------------------------------Amaze your friends! Astound your family! Kennify your text!
If you pass to a coordinate system in which the paddle doesn't move (substract its velocity vector from the disc's), then the rebounding is easy: the disc retains the same speed, but its direction will change by pi-2*alpha with alpha being the angle between the actual contact point and the "head-on" contact point. If R is the sum of the two radii and d is the distance (with sign, as given by (velocity×(center2-center1)).z/|velocity||center2-center1|) by which the center of the disc misses the paddle, then alpha=asin(d/R). After that, you just add back the paddle's velocity and you're done.

[Edited by - Darkstrike on September 26, 2006 12:25:45 PM]
Darkstrike, that is effectively the infinite-mass-paddle solution which the OP says won't do the job. It would be what I'd have suggested too, but since it won't do, let me suggest just setting the component of motion of the puck in the direction of the striker to be equal to the striker's.
I dont mind the infinite mass solution, its just that I encountered problems with that (maybe because I was using the conservation of momentum law at that time, making the smaller ball to bounce very fast)



Ok now I thought of a new approach please tell if this is the right way to go:



Consider smaller disc moving at velocity V1 to teh right, and larger disc at V2 to the left. The black line tangent to the head on collision is what I am considering as a plane surface, and simualting the entire collision as if the disc had hit a wall, the wall being the tangent.

In this case, the ball will rebound such that angle alpha (made by V1 with the normal to the tangent) will be equal and opposite and the velocity unchanged, just like a normal disc-wall collision.

After that, when the new velocity of the disc is found, say V', add it to the the velocity of the larger disc (using vector addition). The new velocity thus will be equal to:
V' + V2

And the larger disc will continue to move without any change in velocity.

Will this be the right way to go? Is there something I have done wrong?



*EDIT*: I got it working with this method. The rebound is just how I wanted it to be. So I'm guessing I'm right then.

[Edited by - Verminox on September 27, 2006 9:04:55 AM]
--------------------------------------Amaze your friends! Astound your family! Kennify your text!

This topic is closed to new replies.

Advertisement