# Sphere collition checking

*281*pages on

this wiki

**Sphere collision checking** is probably the easiest way to provide 3D collision checking in 3D games. To find if two objects are colliding all you have to do is calculate the distances of the two objects geometric origins and check whether it's lesser than the sum of the two objects radii. If it is, then the objects intersect, they have already collided. If it's the same, then they are colliding. And if not, they haven't collided.

pseudocode to calculate distance: xd = x2-x1; yd = y2-y1; zd = z2-z1; Distance = SquareRoot(xd*xd + yd*yd + zd*zd);

x1,x2, y1,y2, z1,z2 are the 3D coordinates of the two objects.

pseudocode to calculate distance avoiding square root. Needs to be written, see between two points at Hugo Elias TGLTLSBFSSP