Distance from point to plane implementation

Calculation of closest points between objects gives us the distance between these objects. These calculations are one of the most powerful in collision detection algorithms in a sense that they can minimize calculations a lot. If the combined maximum movement of the objects is less than the distance between them, a collision will not occur and we can save us a lot of time detecting the impact.

Sphere vs AABB collision detection test

As the sphere is being the simplest primitive there is, the test for Sphere and AABB intersection is easy. This solution works also for Sphere Cube intersection tests.

Basic primitives

Introduction

When you want to do real time computer physics, like what we see in games, you will have to break the world into understandable items. It’s like Caesar’s divide and conquer tactic. When you are playing in a complex scene, all what really goes on in the physics engine is broken into small, but many pieces. This enables further optimization down the line, which will be covered later, but for now this keeps the collision detection and collision response algorithms easy to understand.

Simple AABB vs AABB collision detection

What is AABB? An AABB is an axis aligned bounding box. AABB vs AABB is a box vs box or bounding box collision detection. It’s mainly used in broadphase physics detection.

Collision detection in practice

There are a number of methods to choose when programming a collision detection. They vary from simple to complex and from accurate to not at all.

Advanced Sphere-Sphere Continuous Collision Detection (CCD)

In simple collision detection algorithm we have calculated whether the two spheres were colliding. More advanced calculations include finding the time of the collision as well as the direction of the spheres during the test.

Simple Sphere-Sphere Collision Detection and Collision Response

Collision Detection

To determine if two spheres are colliding, we take the sum of the radiuses and compare it with the length from the centers of the spheres. If the length is smaller than the sum of the radiuses, we have a collision.