CodingTrain / CodingTrain/Suggestion-Box

Coding Challenge: GJK algorithm

Open
#999 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

The [Gilbert-Johnson-Keerthi algorithm](https://en.wikipedia.org/wiki/Gilbert%E2%80%93Johnson%E2%80%93Keerthi_distance_algorithm) (known as GJK) is apparently a highly efficient and commonly used method for determining if 2 arbitrary **convex** polygons intersect. From my recent research into it, it seems that a number of papers and articles written about it make it seem more difficult than it is by obfuscating the algorithm with a lot of complicated math. A [video explaining the algorithm](https://caseymuratori.com/blog_0003) was recommended in the book _Game Engine Architecture_ (Jason Gregory), and this video is also linked to on the wikipedia article discussing the algorithm.

I'm proposing that you implement this algorithm as a coding challenge for a few reasons:

1. It's a somewhat 'difficult' algorithm, but not ridiculously so, making it a challenge that's within reach for the majority of your audience. It's also surprisingly ingenious.
2. The functionality would be very useful. I suspect a lot of the folks watching Coding Train are at least somewhat interested in making games and so could benefit from learning about algorithm for doing "collision detection" besides circle-circle and AABB-AABB. No doubt the GJK is also useful for non-gaming sketches. I'm personally interested in using it for a shape-packing sketch, for example.
3. ???
4. Fun!

For simplicity and to make it more useful as a teaching aid, implementing only the 2D case would be enough. Then you don't have to go through the trouble of dealing with all the extra checks required for a tetrahedron.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.