Skip to content
imbcmdth edited this page Sep 13, 2010 · 31 revisions

RTree ( max_node_width )

Parameters:

max_node_width : optional : The maximum width of a node before a split is forced. Defaults to 6.

Returns:

A new and empty RTree object.

Usage:

var myRTree = new RTree(10); // Makes a new RTree with a max node width of 10.

RTree.count ( area_to_search )

Parameters:

area_to_search : required : An area to search within.

Returns:

The number of objects that overlap or touch area_to_search.

Usage:

var myCount = myRTree.count({x:10, y:10, w:10, h:10}); // searches a 10×10 area that starts at position 10×10.

RTree.search ( area_to_search )

Parameters:

area_to_search : required : An area to search within.

Returns:

An array of objects that overlap or touch area_to_search.

Usage:

var myObjects = myRTree.search({x:10, y:10, w:10, h:10}); // searches a 10×10 area that starts at position 10×10.

RTree.insert ( bounding_box, object_to_insert )

Parameters:

bounding_box : required : A minimally bounding box for object_to_insert.
object_to_insert : required : An object to add to the R-Tree.

Returns:

Nothing.

Usage:

myRTree.insert({x:10, y:10, w:10, h:10}, myObject); // inserts a 10×10 object that starts at position 10×10.

RTree.remove ( area_to_search, object_to_remove )

Parameters:

area_to_search : required : An area to search within.
object_to_remove : optional : An object to remove from the R-Tree. If no object is specified, all objects touching area_to_search are deleted.

Returns:

The number of objects deleted from the R-Tree.

Usage:

myRTree.delete({x:10, y:10, w:10, h:10}); // deletes all object that touch the 10×10 rectangle starting at position 10×10.
myRTree.delete({x:10, y:10, w:10, h:10}, specific_object); // deletes only specific_object if it touches the 10×10 rectangle starting at position 10×10.

Clone this wiki locally