# Collision Detection using a Quadtree

**URL:** <https://discourse.processing.org/t/collision-detection-using-a-quadtree/49130>\
**Category:** Gallery\
**Created:** [August 9, 2026, 1:05pm UTC](https://discourse.processing.org/t/collision-detection-using-a-quadtree/49130 "2026-08-09T13:05:40Z")\
**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 9, 2026, 1:05pm UTC](https://discourse.processing.org/t/collision-detection-using-a-quadtree/49130/1 "2026-08-09T13:05:40Z")

</div>

In this demonstration I am using a quadtree to optimise collision detection. It is the third in a series of topics I have posted on collision detection, the first two being -  
[Collision Detection using Spatial Hashing](https://discourse.processing.org/t/collision-detection-using-spatial-hashing/49088)  
[Collision Detection using Sweep and Prune](https://discourse.processing.org/t/collision-detection-using-sweep-and-prune/49119)

All three sketches use the same core code for the particle and vector classes so these would have to be included if you plan to use one of these in your own code.

You can find all of these sketches in my p5js sketch editor [account](https://editor.p5js.org/quark-js/sketches).

All three sketches have the same initial starting particle domain configuration and appear to have similar performance metrics but I have not performed any serious testing to validate that.

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

---

<div class="post-metadata">

**Author:** ![Boleeman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/boleeman/32/21972_2.png) [@Boleeman](https://discourse.processing.org/u/Boleeman)\
**Post date:** [August 10, 2026, 3:17am UTC](https://discourse.processing.org/t/collision-detection-using-a-quadtree/49130/2 "2026-08-10T03:17:02Z")

</div>

Nice Quadtree collision demo Quark.
