QuadTree
A node in an adaptive quadtree over a Rectangle, as described in https://www.mattkeeter.com/projects/contours/
A region is recursively split into four children -- lower-left, lower-right, upper-left and upper-right, in that order -- down to some maximum depth, where subtrees that are fully inside (isFull) or fully outside (isEmpty) the shape collapse into a single childless node instead. A childless node that is neither isFull nor isEmpty (isLeaf) is a cell that straddles the boundary.
Constructors
Functions
Finds the dual graph of this, as described in https://www.mattkeeter.com/projects/contours/: one point per leaf cell (its center), and one polygon for every grid vertex shared by two or more leaves -- a quad where four same-depth leaves meet, or a triangle at a "hanging" T-junction where one coarser leaf borders two finer ones.