nontree.NonTree
A class for efficient collision detection of points in a sparse 2D plane.
Based on the well known Quadtree data structure.
This is a variant that splits each plane into 9 sub-trees in a 3 by 3 grid.
Parameters
- rect: A rectangle in the shape of (x, y, width, height).
- lvl: Maximum nesting depth. None for automatic heuristic value. >= 0
- bucket: Maximum number of points in a tree, before it is split into subtrees. >= 1
Raises
- ValueError: If lvl, bucket is out of bounds.
Removes a point from the tree.
Parameters
- point: A data point in the shape of (x, y).
Gets all points that are within the tree.
Returns
A list of points in the shape of (x, y).
Gets all points that are within a rectangle.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
Returns
A list of points in the shape of (x, y).
Gets all points that are within a circle.
Parameters
- circ: A circle in the shape of (x, y, radius).
Returns
A list of points in the shape of (x, y).
Gets point if it is in the tree.
Parameters
- point: A point in the shape of (x, y).
Returns
A list of point in the shape of (x, y).
Tests if there are points within a rectangle.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
Returns
True if there are points within the rectangle, False if not.
Tests if there are points within a circle.
Parameters
- circ: A circle in the shape of (x, y, radius).
Returns
True if there are points within the circle, False if not.
Tests if point is in the tree.
Parameters
- point: A point in the shape of (x, y).
Returns
True if point is in the tree, False if not.
Deletes all points that are within the tree.
Returns
A list of deleted points.
Deletes points within a rectangle.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
Returns
A list of deleted points.
Deletes points within a circle.
Parameters
- circ: A circle in the shape of (x, y, radius).
Returns
A list of deleted points.
Deletes a point from the tree.
Parameters
- point: A point in the shape of (x, y).
Returns
A list of deleted point.
Test if rectangle encompasses rectangle.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
- other_rect: A rectangle in shape of (x, y, width, height).
Returns
True if rect encompasses other_rect, False if not.
Test collision between rectangle and point.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
- point: A point in the shape of (x, y).
Returns
True if collision, False if not.
Test collision between rectangle and rectangle.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
- other_rect: A rectangle in shape of (x, y, width, height).
Returns
True if collision, False if not.
Test if circle encompasses rectangle.
Parameters
- circ: A circle in the shape of (x, y, radius).
- rect: A rectangle in shape of (x, y, width, height).
Returns
True if circ encompasses rect, False if not.