A Practical Exploration of Collision Detection in Modern C++
Collisions is a C++ project exploring the mathematics and software engineering behind collision detection and collision response through a real-time sphere simulation. Multiple spheres are simulated under gravity as they fall into an inverted pyramid, interacting with one another and the surrounding environment through specialised collision algorithms.
Rather than focusing on gameplay or engine architecture, the project investigates how geometric primitives, collision detection techniques and response calculations combine to produce believable physical interactions while maintaining a clear and organised software structure.
The Engineering Problem
Real-time collision systems must reliably detect interactions between moving objects while producing stable and predictable responses. Even in a relatively simple simulation, multiple moving bodies, static boundaries and repeated collisions create challenges involving collision timing, contact resolution and maintaining physically plausible behaviour.
The objective of this project was to explore these challenges by implementing the collision detection and response required for a simulation of interacting spheres contained within an inverted pyramid. Rather than developing a complete physics engine, the project investigates the core mathematical techniques that underpin collision processing in real-time applications.
My Role
I designed and implemented the collision detection algorithms, collision response calculations and supporting mathematical systems used throughout the simulation. This included developing sphere-to-sphere and sphere-to-environment collision handling, implementing response calculations following impact and structuring the project into focused components with clearly defined responsibilities.
The project demonstrates practical software engineering through computational geometry, vector mathematics and modular C++ design while exploring the behaviour of multiple interacting bodies in a real-time simulation.
Simulation Demonstration

Spawn Modes
Demonstrates configurable sphere spawning behaviours.

Rendering Modes
Demonstrates available rendering modes and perspective.

Collision Response
Demonstrates the simulation through the simulation.
Architecture Overview
The simulation is organised as a layered collision processing pipeline that separates object representation, collision detection and collision response into independent areas of responsibility.

Simulation objects provide geometric representations used by the collision system. Detection algorithms determine when spheres collide with one another or the surrounding pyramid, while response calculations generate updated positions and velocities that allow the simulation to continue in a stable and predictable manner.
Core Collision Systems
The project is organised into focused components that separate mathematical representation, collision detection and collision response. Each system performs a specific responsibility while contributing to the overall simulation.

Simulation Objects
Represents the moving spheres and the static pyramid geometry that define the physical environment. These geometric representations provide the information required for collision detection without embedding mathematical calculations directly into the simulation objects.

Collision Detection
Implements the algorithms that are responsible for identifying collisions between the moving spheres and between moving spheres and the pyramid boundaries. Detection routines determine when collisions occur and calculate the information required for subsequent response calculations.

Collision Response
Calculates collision normals, penetration correction and updated velocities following collision detection. These response calculations ensure that spheres react consistently to impacts with both neighbouring spheres and the enclosing environment, producing a real-time simulation.
Together, these systems demonstrate how collision processing can be organised into clear, maintainable components while supporting complex interactions between multiple moving objects.
Engineering Principles
| Principle | Application |
| Separation of Concerns | Simulation objects, collision detection and collision response are implemented as independent systems with clearly defined responsibilities. |
| Single Responsibility | Individual components focus on representing geometry, detecting collisions or resolving impacts without combining unrelated behaviour. |
| Modular Design | Collision processing is organised into focused components that make individual algorithms easier to understand and modify. |
| Computational Geometry | Collision calculations are based on mathematical representations of spheres, planes and surface geometry rather than application-specific logic. |
| Collision Response | Detection and response remain separate stages, allowing impacts to be resolved consistently using calculated collision information. |
| Deterministic Behaviour | Identical simulation conditions produce consistent collision behaviour, making the project easier to analyse and debug. |
| Composition Over Duplication | Shared mathematical operations and vector calculations are reused throughout the collision processing pipeline. |
| Extensibility | The organisation of the project allows additional collision scenarios and geometric primitives to be explored without restructuring the overall design. |
| Performance Awareness | DirectXMath vector operations support efficient mathematical computation while maintaining readable implementations. |
| Clear Ownership | Each subsystem owns a distinct aspect of the collision process, making interactions easier to understand and maintain. |
Key Design Decisions
Separation of Detection and Response
Collision detection is responsible for determining when collisions occur, while dedicated response calculations determine how objects react following impact. Separating these responsibilities simplifies both implementation and experimentation.
Sphere-Based Simulation
Using spheres as the primary dynamic objects allows the project to focus on collision mathematics and response behaviour without introducing unnecessary geometric complexity.
Environment as Static Geometry
The inverted pyramid acts as a fixed collision boundary, allowing the project to investigate interactions between dynamic and static objects while maintaining a controlled simulation environment.
Stable Multi-Object Interactions
The simulation supports repeated collisions between multiple moving spheres while maintaining predictable behaviour, providing a practical environment for investigating collision processing techniques.
Technologies
Development
C++
Visual Studio
Git
Engineering Approach
Collision Detection
Collision Response
Computational Geometry
Real-Time Simulation
Rigid Body Interaction
DirectXMath
SIMD Vector Mathematics
Object-Orientated Design
Modular Software Design
Separation of Concerns
Mathematical Optimisation
Engineering Outcome
Collisions demonstrates an understanding of the mathematical and software engineering principles involved in real-time collision processing through the implementation of a multi-body sphere simulation. By investigating interactions between moving spheres and a static environment, the project explores how collision detection, collision response and computational geometry combine to produce stable and predictable simulation behaviour.
Rather than functioning as a complete physics engine, the project serves as a practical investigation into collision processing, demonstrating experience with vector mathematics, geometric algorithms and the organisation of complex technical concepts into a structured C++ application.
Application Gallery






Repository
Explore the source code to see how the architectural principles are implemented throughout the framework.
