Get the latest tech news
Sort, sweep, and prune: Collision detection algorithms (2023)
Thanks for reading! I like making interactive visualisations for my programming blog. Sometimes I do projects too.
As hinted above, optimising in just one axis can still make a big difference later, so we’ll focus on this single check for now. As shown by the tri-object example above, to achieve the power to skip tests we need to sort the list of objects by x position. This is a super good improvement over the naive approach’s O(n 2), because[1] n log n is much smaller than n 2 and[2] it is partially output-based - depending on the number of overlaps, it does not process more than necessary.
Or read this on Hacker News