<p>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?</p>

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

[{'answer_id': 31171, 'author': 'Frank Krueger', 'author_id': 338, 'author_profile': 'https://Stackoverflow.com/users/338', 'pm_score': 2, 'selected': False, 'text': '<p>Personally, I love the work of <a href="http://www.paulbourke.net/" rel="nofollow noreferrer">Paul Bourke</a>.</p>\n<p>Also, Paul Nettle used to write on the topic. He has a full 3D collision detection library, but you may be more interested in the ideas behind such libraries (which are very applicable to 2D). For that, see <a href="http://www.gamedev.net/reference/articles/article1026.asp" rel="nofollow noreferrer">General Collision Detection for Games Using Ellipsoids</a>.</p>\n'}, {'answer_id': 31186, 'author': 'Anders Sandvig', 'author_id': 1709, 'author_profile': 'https://Stackoverflow.com/users/1709', 'pm_score': 0, 'selected': False, 'text': '<p>If your objects are represented as points in 2D space you can use line intersection to determine if two objects have collided. You can use similar logic to check if an object is inside another object (and thus they have collided even any of their lines are not currently intersecting). The <a href="http://paulbourke.net/geometry/pointlineplane/" rel="nofollow noreferrer">math to do this</a> is quite simple, and should be covered by any textbook on basic geometry. Detecting if an object has passed completely through an object might be a bit more tricky though. </p>\n'}, {'answer_id': 36524, 'author': 'Nikhil', 'author_id': 853, 'author_profile': 'https://Stackoverflow.com/users/853', 'pm_score': 2, 'selected': False, 'text': '<p>Metanet Software has published <a href="http://www.harveycartel.org/metanet/tutorials.html" rel="nofollow noreferrer">some relevant tutorials</a>.  Metanet develops <a href="http://www.thewayoftheninja.org/n.html" rel="nofollow noreferrer">N</a> (Flash-based, for Windows, Mac, Linux) and <a href="http://www.thewayoftheninja.org/n_future.html" rel="nofollow noreferrer">N+</a> (for the X360, DS, and PSP).</p>\n'}, {'answer_id': 40157, 'author': 'Slacker', 'author_id': 4053, 'author_profile': 'https://Stackoverflow.com/users/4053', 'pm_score': 1, 'selected': False, 'text': "<p>The book 'Real-Time Collision Detection' by Christer Ericson (ISBN: 1-55860-732-3) is a recent (2005) and widely praised book which should give you some good answers.</p>\n\n<p>It starts with a basic primer of some of the maths you will need to know, and then goes into various types of bounding volumes (spheres, axis-aligned bounding boxes, oriented bounding boxes) commonly used in collision detection.</p>\n\n<p>Next up for discussion are numerous algorithms for detecting collisions between various combinations of primitives, such as lines, triangles, spheres, polygons, planes, bounding volumes etc.</p>\n\n<p>Also of importance is the coverage of some of the major methods of spatial division and organisation of your objects (volume hierarchies, BSP trees, Octrees, etc.). This essentially speeds up collision detection, as it allows you to subdivide your objects so you can avoid unnecessary comparisons between objects (e.g. I know from my data structures that object A is too far away to hit object B, so I won't even do a distance check).</p>\n\n<p>It also includes some coverage of how to actually check for collisions between moving objects (intervals, etc) but be aware that even though this is a fairly hefty book and covers the material well, it is for collision <em>detection</em>, not <em>resolution</em> or <em>response</em>.  So it will help you determine whether two objects have collided, but not really what to do about it, i.e. how to resolve it.  The intersection tests will usually give you the data you need to make such decisions, but in terms of the general problem of writing a <em>solver</em>, which uses collision detection routines to detect collisions and then decide what to do about them, this book does not cover that in depth.</p>\n"}, {'answer_id': 88924, 'author': 'Jeff', 'author_id': 16639, 'author_profile': 'https://Stackoverflow.com/users/16639', 'pm_score': 4, 'selected': False, 'text': '<p>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.</p>\n\n<p><a href="http://en.wikipedia.org/wiki/Sweep_and_prune" rel="noreferrer">Sweep and Prune</a> 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 <a href="http://sourceforge.net/projects/bullet" rel="noreferrer">Bullet</a> library has a 3d implementation for reference.</p>\n\n<p>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, <a href="http://www.dtecta.com/" rel="noreferrer">GJK</a> 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 ;)</p>\n\n<p>Finally, after you have collision detection, you are often in need of some sort of collision response.  <a href="http://www.box2d.org/" rel="noreferrer">Box 2d</a> is a good starting point for a physical response solution.</p>\n'}]
['https://Stackoverflow.com/questions/31158', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2772/']