ELI5: Explain Like I'm 5

Gilbert–Johnson–Keerthi distance algorithm

So, the Gilbert-Johnson-Keerthi (GJK) distance algorithm is a way to find out how far apart two shapes are from each other. Imagine you have two toys - one is a square block, and the other is a round ball. You want to know how far the ball is from the block.

Now, imagine you have a flashlight and you shine it on the ball. You can see the part of the ball that's light up by the flashlight, but you can't see the rest of it. You move the flashlight around and you see different parts of the ball, but still not the whole thing. The GJK algorithm works kind of like this - it shines a theoretical flashlight around the shape to see different parts of it.

But, instead of using a flashlight, the GJK algorithm uses something called a "support function". A support function tells you what point on a shape is furthest in a certain direction. So, if you imagine the ball again, the support function would tell you where the ball is the thickest in a certain direction.

The algorithm starts by picking a random point on both shapes (like a random point on the block and a random point on the ball). Then, it finds the direction of the closest distance between those two points. Once it has that direction, it uses the support function to find the point on each shape that's furthest in that direction.

Then, it repeats this process until it finds the closest distance between the two shapes. So, it finds a new direction based on the line connecting the two furthest points it found, and then uses the support function to find two new furthest points. It keeps doing this until it gets close enough to the true closest distance between the shapes.

So, in summary, the GJK distance algorithm uses a support function to find the furthest point on a shape in a certain direction, and then repeats that process to find the closest distance between two shapes. It's kind of like a theoretical flashlight that shines around the shape to find different parts of it.