Circle collision is much easier, only need to determine distance between centers > sum of radius.
Determine 2 rectangles without rotation is collided or not.
Check the bounds of each rectangle with width & height
That is check :
All of above conditions are satisfied.
Represents an axis aligned bounding box.
An axis-aligned bounding box, or AABB for short, is a box aligned with coordinate axes and fully enclosing some object. Because the box is never rotated with respect to the axes, it can be defined by just its center and extents, or alternatively by min and max points.
Separating Axis Theorem (SAT for short) states if you are able to draw a line to separate two polygons, then they do not collide.
If we can find out separate axis,
two polygons doesn’t collide each other.
Find out separate axis of 2 polygons.
How to find SAT?
Just like Axis-Aligned Bounding Box,
project each vertice onto each edge.
(AABB method use x-y axes to detect)
- It’s not reasonable to search all axes for finding a SAT.
- Select the candidate axes for finding SAT!
- The axes must test are the normals of each edges from shapes.
- Find all normals from each shape
- Find all project point for all vertices on each normal
- Find if there is at least 1 separate axis or not.
(projection1.max > projection2.min && project2.max > projection.min)
Tracking the the minimum overlap and axis when we finding SAT.
Use this vector to separate shapes.
Discrete simulation can lead to missed collisions and tunneling. In this case the ball falls out of the world.
Some of CCD resources: