Circle vs Edge collision detection / resolution

Posted by topheman on Game Development See other posts from Game Development or by topheman
Published on 2012-10-25T18:42:57Z Indexed on 2012/10/25 23:17 UTC
Read the original article Hit count: 269

I made a javascript class Ball.js that handles physics interactions betweens balls as well as painting. In the v1.0, the ball vs ball collision detection and resolution is well handled.

In the next version (v2), I'm trying to add edgeCollision handling. I'm having some problems, maybe you will be able to help me.

All the v2 branch source code is on github repository : https://github.com/topheman/Ball.js/tree/v2

The v2 demos (where you can see the bug I will be talking about) : http://labs.topheman.com/Ball-v2/#help

As you will see on the demo, I have two major problems that I'm having a really hard time to solve on Ball.js :

  • method resolveEdgeCollision : bounce angle is inconsistent
  • method checkEdgeCollision : if the ball's velocity (the length that it runs each frame) is higher than its diameter, eventually, it will pass through an edge, without triggering any collision

Any Ideas ?...

© Game Development or respective owner

Related posts about collision-detection

Related posts about JavaScript