QuadNode¶
-
class
quads.
QuadNode
(center, width, height, capacity=None)¶ A node within the QuadTree.
Typically, you won’t use this object directly. The QuadTree object provides a more convenient API. However, if you know what you’re doing or need to customize, QuadNode is here.
-
all_points
()¶ Returns a list of all the points located within a node & its children.
Returns: All the Point objects in an unordered list. Return type: list
-
bb_class
¶ alias of
BoundingBox
-
contains_point
(point)¶ Checks if a point would be within the bounding box of the node.
This is a bounding check, not verification the point is present in the data.
Parameters: point (Point) – The point to check. Returns: True if it is within the bounds, otherwise False. Return type: bool
-
find
(point)¶ Searches for the node that would contain the Point within the node & it’s children.
Parameters: point (Point) – The point to search for. Returns: - Returns the Point (including it’s data) if found.
- None if the point is not found.
Return type: Point|None
-
find_node
(point, searched=None)¶ Searches for the node that would contain the Point within the node & it’s children.
Parameters: - point (Point) – The point to search for.
- searched (list|None) – Optional. This is a list of all the nodes that were touched during the search. Default is None, which will construct an empty list to pass to recursive calls.
Returns: - (QuadNode|None, list): Returns the node where the point
would be found or None, AND the list of nodes touched during the search.
Return type: tuple
-
insert
(point)¶ Inserts a Point into the node.
If the node exceeds the maximum capacity, it will subdivide itself & redistribute its points before adding the new one. This means there can be some variance in the performance of this method.
Parameters: point (Point) – The point to insert. Returns: True if insertion succeeded, otherwise False. Return type: bool
-
is_ll
(point)¶ Checks if a point would be in the lower-left quadrant of the node.
This is a bounding check, not verification the point is present in the data.
Parameters: point (Point) – The point to check. Returns: True if it would be, otherwise False. Return type: bool
-
is_lr
(point)¶ Checks if a point would be in the lower-right quadrant of the node.
This is a bounding check, not verification the point is present in the data.
Parameters: point (Point) – The point to check. Returns: True if it would be, otherwise False. Return type: bool
-
is_ul
(point)¶ Checks if a point would be in the upper-left quadrant of the node.
This is a bounding check, not verification the point is present in the data.
Parameters: point (Point) – The point to check. Returns: True if it would be, otherwise False. Return type: bool
-
is_ur
(point)¶ Checks if a point would be in the upper-right quadrant of the node.
This is a bounding check, not verification the point is present in the data.
Parameters: point (Point) – The point to check. Returns: True if it would be, otherwise False. Return type: bool
-
subdivide
()¶ Subdivides an existing node into the node + children.
Returns: Nothing to see here. Please go about your business. Return type: None
-
within_bb
(bb)¶ Checks if a bounding box is within the node’s bounding box.
Primarily for internal use, but stable API if you need it.
Parameters: bb (BoundingBox) – The bounding box to check. Returns: True if the bounding boxes intersect, otherwise False. Return type: bool
-