Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AOI ¶
type AOI interface {
Add(x, y float64, name string) // Add an entity to the AOI
Delete(x, y float64, name string) // Delete an entity from the AOI
Search(x, y float64) (result []string) // Search for entities within a specified range
}
AOI (Area of Interest) represents an interface for managing entities within a specific area.
func NewGridManager ¶
NewGridManager initializes a new GridManager with the specified parameters.
func NewQuadTree ¶
NewQuadTree initializes a new QuadTree with the specified parameters.
type GridManager ¶
type GridManager struct {
StartX int // X-coordinate of the left boundary of the AOI
StartY int // Y-coordinate of the upper boundary of the AOI
AreaWidth int // Width of each grid (assuming square grids)
GridCount int // Number of grids in each row/column
// contains filtered or unexported fields
}
GridManager implements AOI (Area of Interest) using a rectangular grid.
func (*GridManager) Add ¶
func (g *GridManager) Add(x, y float64, key string)
Add adds an entity to the appropriate grid based on its coordinates.
func (*GridManager) Delete ¶
func (g *GridManager) Delete(x, y float64, key string)
Delete removes an entity from the grid based on its coordinates.
func (*GridManager) Search ¶
func (g *GridManager) Search(x, y float64) []string
Search retrieves a list of entity keys within the specified coordinates' range.
type Node ¶
type Node struct {
Leaf bool // Indicates whether the node is a leaf node
Deep int // Depth of the node in the quadtree
AreaWidth float64 // Width of the grid (assuming square grids)
XStart float64 // Starting X-coordinate of the node's area
YStart float64 // Starting Y-coordinate of the node's area
Tree *QuadTree // Pointer to the quadtree
Child [4]*Node // Child nodes (quadrants)
Entities *sync.Map // Entities within the node
}
Node represents a node in the quadtree.
func NewSonNode ¶
NewSonNode creates a new child node with the specified parameters.