# Collision Detection using Spatial Hashing

**URL:** <https://discourse.processing.org/t/collision-detection-using-spatial-hashing/49088>\
**Category:** Gallery\
**Created:** [August 1, 2026, 9:52am UTC](https://discourse.processing.org/t/collision-detection-using-spatial-hashing/49088 "2026-08-01T09:52:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [August 1, 2026, 9:52am UTC](https://discourse.processing.org/t/collision-detection-using-spatial-hashing/49088/1 "2026-08-01T09:52:25Z")

</div>

I have found a great YouTube channel [Ten Minute Physic](https://www.youtube.com/@TenMinutePhysics/home) and in particular this [video](https://www.youtube.com/watch?v=D2M8jTtKi44&t=393s) on the spatial hashing algorithm. The sketch below is based on the algorithms described in this video.

Although I have not performed any serious performance tests it appears to be of the same order of magnitude as a [quadtree implementation](https://openprocessing.org/@Quark/1684733) but has a much simpler code implementation.

The[full sketch code](https://editor.p5js.org/quark-js/sketches/SCXK0rmt1) is available in the p5js web editor. If you use the p5js editor to create a copy make sure you turn off “Loop Protection" for best performance.

https://editor.p5js.org/quark-js/full/SCXK0rmt1

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [August 2, 2026, 9:40am UTC](https://discourse.processing.org/t/collision-detection-using-spatial-hashing/49088/4 "2026-08-02T09:40:16Z")

</div>

This reply was deleted by Quark
