Home /  Sketchbook /  p5.js - Common Examples - Quadtree 2
  • Info

Overview

This is a p5.js sketch to demonstrate an implementation of a Quadtree data structure.

Specifically, this enables a type referred to as a Polygonal Map, though limited to storing rectangles. The Quadtree class can still store points as well, with an optional containsPoints parameter defaulting to true for the original implementation.

Controls

Mouse

  • Move - Highlights the rectangles centered around the mouse.

Touch

  • Touch and Drag - Highlights the rectangles centered around the main touch point.

References:

  • Wikipedia - Quadtree - Polygonal Map (PM)
  • Coding Train Episode 98.1 98.2

Links:

  • Live View
  • Source on Github

Screenshot:

screenshot