Chapter 5. 2D Collisions

With the basic primitive shapes defined, we can start testing for collisions. In this chapter, we are going to implement the following collision tests:

  • Circle to circle
  • Circle to rectangle
  • Circle to oriented rectangle
  • Rectangle to rectangle
  • Separating Axis Theorem
  • Rectangle to oriented rectangle
  • Oriented rectangle to oriented rectangle

Introduction

At this point, we know what the basic 2D primitive shapes are; now it's time to explore if two of them intersect. Some of these intersections are going to be simple to find, others will be a bit more challenging. For example, checking if two spheres intersect takes only a few lines of code, checking if two oriented boxes intersect requires much more work

We are going to cover the Separating ...

Get Game Physics Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.