A Quadtree is a spatial partioning tree structure meant to provide fast spatial queries such as nearest points within a range.
val box = Rectangle.fromCenter(Vector2(400.0), 750.0)
val quadTree = Quadtree<Vector2>(box) { it }
for (point in points) {
quadTree.insert(point)
}
val nearestQuery = quadTree.nearest(points[4], 20.0)
Ricardo Matias / @ricardomatias