Point in Sphere

Calculating to see if a point is inside a sphere is a very simple task. We just need to check the distance between the center of the sphere to the point and compare it with the sphere’s radius. If this distance is less than the radius, then the point is inside the sphere. If the distance is the same, then the point is on the sphere’s edge. In this example, we will consider Read More

AABB to AABB

Axis Aligned Bounding Boxes (AABBs for short) are very easy to make. They are basically non-rotated boxes. They can be made by having a max point and a min point or by having a center point and width/height/depth. For this example, I will use an AABB created with two points (min and max). The collision check between two AABBs is very simple and fast, since it has many early outs. The bad thing Read More

Point in AABB

Axis Aligned Bounding Boxes (AABBs for short) are very easy to make. They are basically non-rotated boxes. They can be made by having a max point and a min point or by having a center point and width/height/depth. For this example, I will use an AABB created with two points (min and max). To check if a point is inside an AABB we just need to check if all its values (x,y Read More

Sphere to Sphere Collision

Collisions between spheres are very simple and easy to perform. An advantage that spheres have over things like AABBs (Axis-Aligned Bounding Boxes) is that it doesn't matter if the object rotates, the sphere will remain the same. We need to calculate the distance between the centers of the spheres and compare it to the sum of their radii. If this distance is less than the sum of their radii, then the spheres Read More