Node = function(tree, a, b)
{
    this.obj = null;
    this.bb_l = min(a.bb_l, b.bb_l);
    this.bb_b = min(a.bb_b, b.bb_b);
    this.bb_r = max(a.bb_r, b.bb_r);
    this.bb_t = max(a.bb_t, b.bb_t);
    this.parent = null;
    
    this.setA(a);
    this.setB(b);
}
@defgroup cpSpatialIndex cpSpatialIndex

    Spatial indexes are data structures that are used to accelerate collision detection
    and spatial queries. Chipmunk provides a number of spatial index algorithms to pick from
    and they are programmed in a generic way so that you can use them for holding more than
    just Shapes.

    It works by using pointers to the objects you add and using a callback to ask your code
    for bounding boxes when it needs them. Several types of queries can be performed an index as well
    as reindexing and full collision information. All communication to the spatial indexes is performed
    through callback functions.

    Spatial indexes should be treated as opaque structs.
    This means you shouldn't be reading any of the fields directly.

    All spatial indexes define the following methods:

    // The number of objects in the spatial index.
    count = 0;

    // Iterate the objects in the spatial index. @c func will be called once for each object.
    each(func);

    // Returns true if the spatial index contains the given object.
    // Most spatial indexes use hashed storage, so you must provide a hash value too.
    contains(obj, hashid);

    // Add an object to a spatial index.
    insert(obj, hashid);

    // Remove an object from a spatial index.
    remove(obj, hashid);

    // Perform a full reindex of a spatial index.
    reindex();

    // Reindex a single object in the spatial index.
    reindexObject(obj, hashid);

    // Perform a point query against the spatial index, calling @c func for each potential match.
    // A pointer to the point will be passed as @c obj1 of @c func.
    // func(shape);
    pointQuery(point, func);

    // Perform a segment query against the spatial index, calling @c func for each potential match.
    // func(shape);
    segmentQuery(vect a, vect b, t_exit, func);

    // Perform a rectangle query against the spatial index, calling @c func for each potential match.
    // func(shape);
    query(bb, func);

    // Simultaneously reindex and find all colliding objects.
    // @c func will be called once for each potentially overlapping pair of objects found.
    // If the spatial index was initialized with a static index, it will collide it's objects against that as well.
    reindexQuery(func);