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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of sort

sort

Photo of Sweep

Sweep

Photo of prune

prune

Related news:

News photo

NumPy 2.0 Brings Faster Performance Thanks To Intel's x86-simd-sort & Google's Highway

News photo

Sweep (YC S23) is hiring a Founding Engineers to build a code generation bot

News photo

Sweep (YC S23) is hiring a Founding ML engineer to build an AI developer