Documentation ¶
Index ¶
- Constants
- type Matcher
- type Node
- type QuadTree
- func (q *QuadTree[T]) All() []Node[T]
- func (q *QuadTree[T]) Clear()
- func (q *QuadTree[T]) ContainedByRect(rect geom.Rect[T]) bool
- func (q *QuadTree[T]) ContainsPoint(pt geom.Point[T]) bool
- func (q *QuadTree[T]) ContainsRect(rect geom.Rect[T]) bool
- func (q *QuadTree[T]) FindContainedByRect(rect geom.Rect[T]) []Node[T]
- func (q *QuadTree[T]) FindContainsPoint(pt geom.Point[T]) []Node[T]
- func (q *QuadTree[T]) FindContainsRect(rect geom.Rect[T]) []Node[T]
- func (q *QuadTree[T]) FindIntersects(rect geom.Rect[T]) []Node[T]
- func (q *QuadTree[T]) FindMatchedContainedByRect(matcher Matcher[T], rect geom.Rect[T]) []Node[T]
- func (q *QuadTree[T]) FindMatchedContainsPoint(matcher Matcher[T], pt geom.Point[T]) []Node[T]
- func (q *QuadTree[T]) FindMatchedContainsRect(matcher Matcher[T], rect geom.Rect[T]) []Node[T]
- func (q *QuadTree[T]) FindMatchedIntersects(matcher Matcher[T], rect geom.Rect[T]) []Node[T]
- func (q *QuadTree[T]) Insert(n Node[T])
- func (q *QuadTree[T]) Intersects(rect geom.Rect[T]) bool
- func (q *QuadTree[T]) MatchedContainedByRect(matcher Matcher[T], rect geom.Rect[T]) bool
- func (q *QuadTree[T]) MatchedContainsPoint(matcher Matcher[T], pt geom.Point[T]) bool
- func (q *QuadTree[T]) MatchedContainsRect(matcher Matcher[T], rect geom.Rect[T]) bool
- func (q *QuadTree[T]) MatchedIntersects(matcher Matcher[T], rect geom.Rect[T]) bool
- func (q *QuadTree[T]) Remove(n Node[T])
- func (q *QuadTree[T]) Reorganize()
- func (q *QuadTree[T]) Size() int
Constants ¶
const ( // DefaultQuadTreeThreshold is the default threshold that will be used if none is specified. DefaultQuadTreeThreshold = 64 // MinQuadTreeThreshold is the minimum allowed threshold. MinQuadTreeThreshold = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matcher ¶
type Matcher[T xmath.Numeric] interface { // Matches returns true if the node matches. Matches(n Node[T]) bool }
Matcher is used to match nodes.
type Node ¶
type Node[T xmath.Numeric] interface { // Bounds returns the node's bounding rectangle. Bounds() geom.Rect[T] }
Node defines the methods an object that can be stored within the QuadTree must implement.
type QuadTree ¶
QuadTree stores two-dimensional nodes for fast lookup.
func (*QuadTree[T]) ContainedByRect ¶
ContainedByRect returns true if at least one node is contained by the rect.
func (*QuadTree[T]) ContainsPoint ¶
ContainsPoint returns true if at least one node contains the point.
func (*QuadTree[T]) ContainsRect ¶
ContainsRect returns true if at least one node contains the rect.
func (*QuadTree[T]) FindContainedByRect ¶
FindContainedByRect returns the nodes that are contained by the rect.
func (*QuadTree[T]) FindContainsPoint ¶
FindContainsPoint returns the nodes that contain the point.
func (*QuadTree[T]) FindContainsRect ¶
FindContainsRect returns the nodes that contain the rect.
func (*QuadTree[T]) FindIntersects ¶
FindIntersects returns the nodes that intersect the rect.
func (*QuadTree[T]) FindMatchedContainedByRect ¶
FindMatchedContainedByRect returns the nodes that the matcher returns true for which are contained by the rect.
func (*QuadTree[T]) FindMatchedContainsPoint ¶
FindMatchedContainsPoint returns the nodes that the matcher returns true for which contain the point.
func (*QuadTree[T]) FindMatchedContainsRect ¶
FindMatchedContainsRect returns the nodes that the matcher returns true for which contains the rect.
func (*QuadTree[T]) FindMatchedIntersects ¶
FindMatchedIntersects returns the nodes that the matcher returns true for which intersect the rect.
func (*QuadTree[T]) Insert ¶
Insert a node. NOTE: Once a node is inserted, the value it returns from a call to Bounds() MUST REMAIN THE SAME until the node is removed.
func (*QuadTree[T]) Intersects ¶
Intersects returns true if at least one node intersects the rect.
func (*QuadTree[T]) MatchedContainedByRect ¶
MatchedContainedByRect returns true if at least one node that the matcher returns true for is contained by the rect.
func (*QuadTree[T]) MatchedContainsPoint ¶
MatchedContainsPoint returns true if at least one node that the matcher returns true for contains the point.
func (*QuadTree[T]) MatchedContainsRect ¶
MatchedContainsRect returns true if at least one node that the matcher returns true for contains the rect.
func (*QuadTree[T]) MatchedIntersects ¶
MatchedIntersects returns true if at least one node that the matcher returns true for intersects the rect.
func (*QuadTree[T]) Reorganize ¶
func (q *QuadTree[T]) Reorganize()
Reorganize the QuadTree to optimally fit its contents.