Spatial Hashes

A spatial hash is one way of indexing objects in space. As Python programmers, we should perhaps call them spatial dicts, but let’s go with the literature on this one. Like a dict, a spatial hash has O(1) properties.

The basic principle is to split space into an infinite number of cells – each cell can contain an arbitrary number of objects. A cell that is empty simply isn’t stored.

Largely taken from

http://themonkeyproject.wordpress.com/2011/05/18/introduction-to-spatial-hashes/

class wasabi.geom.spatialhash.SpatialHash(cell_size=250.0)
add_rect(r, obj)

Add an object obj with bounds r.

potential_intersection(r)

Get a set of all objects that potentially intersect obj.

remove_rect(r, obj)

Remove an object obj which had bounds r.