Skip to content

DavidMcLaughlin/pyquad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

A Quad Tree implementation in Python, which provides the ability to quickly find the closest object 
in the tree to a given point.

   from random import randint
   from quadtree import QuadTree
   
   # create a tree representing a 100 square grid
   tree = QuadTree(Point(0,100), Point(100,0))
   # add some data
   for i in xrange(10000):
       tree.add(Point(randint(0,100), randint(0,100)), "value data")

   # get the closest object to the centre
   print tree.get(Point(50,50)) 

TODO:
   1) Building the tree is O(n) but each call to add is expensive, so need to optimize
   2) Rather than maxsize and minsize, should base the tree on a depth property

About

Quad Tree implemented in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages