# 10th Floor/programming

# Collision

- Sphere to Sphere collision
- Each sphere is described by an x and y co-ordinate located in the very center, as well as a radius.
- If the distance between each sphere is less than the sum of their radius's, then a collision has occurred.

**Sphere to Sphere Collision **

int collision_sphere (x_sphere1, y_sphere1, r_sphere1, x_sphere2, y_sphere2, r_sphere2){ int collision = 0; double distance = √(x_sphere1 - x_sphere2)² + (y_sphere1 - y_sphere2)²; // calculate distance if ((r_sphere1 + r_sphere2) > distance){ // compare to sum of radius collsion = 1; } return collsion; }