Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resources of techniques use for collision detection in 2D? [closed]

What are in your opinion the best resources (books or web pages) describing algorithms or techniques to use for collision detection in a 2D environment?

I'm just eager to learn different techniques to make more sophisticated and efficient games. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­

like image 1000
borrego Avatar asked Aug 27 '08 20:08

borrego


1 Answers

Collision detection is often a two phase process. Some sort of "broad phase" algorithm for determinining if two objects even have a chance of overlapping (to try to avoid n^2 compares) followed by a "narrow phase" collision detection algorithm, which is based on the geometry requirements of your application.

Sweep and Prune is a well established efficient broad phase algorithm (with a handful of variants that may or may not suit your application) for objects undergoing relatively physical movement (things that move crazy fast or have vastly different sizes and bounding regions might make this unsuitable). The Bullet library has a 3d implementation for reference.

Narrow phase collision can often be as simple as "CircleIntersectCircle." Again the Bullet libraries have good reference implementations. In 3d land when more precise detection is required for arbitrary objects, GJK is among the current cream of the crop - nothing in my knowledge would prevent it from being adapted to 2d (but it might end up slower than just brute forcing all your edges ;)

Finally, after you have collision detection, you are often in need of some sort of collision response. Box 2d is a good starting point for a physical response solution.

like image 108
Jeff Avatar answered Nov 16 '22 01:11

Jeff