Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Positioned a => QuadTree a
- = QuadEmpty
- | QuadLeaf a
- | QuadBranch (QuadTree a) (QuadTree a) (QuadTree a) (QuadTree a) BoundingBox
- data QuadDir
- buildQuadTree :: Positioned a => BoundingBox -> [a] -> QuadTree a
- calcQuadDir :: Positioned a => a -> BoundingBox -> QuadDir
- nearestQuad :: (Positioned a, Positioned b) => a -> QuadTree b -> Maybe b
- quadTreeToList :: Positioned a => QuadTree a -> [a]
Documentation
data Positioned a => QuadTree a Source #
A QuadTree for faster search queries
QuadEmpty | |
QuadLeaf a | |
QuadBranch (QuadTree a) (QuadTree a) (QuadTree a) (QuadTree a) BoundingBox |
Posibble directions within a branch (negative x && negative y | negative x && positive y ...)
buildQuadTree :: Positioned a => BoundingBox -> [a] -> QuadTree a Source #
Builds a QuadTree from a list of elements with positions The BoundingBox should be the BoundingBox of the elements
calcQuadDir :: Positioned a => a -> BoundingBox -> QuadDir Source #
Helper function to decide into which sub-node a position belongs
nearestQuad :: (Positioned a, Positioned b) => a -> QuadTree b -> Maybe b Source #
Finds the nearest within the tree to the search position (if there is any)
quadTreeToList :: Positioned a => QuadTree a -> [a] Source #
Puts the elements of a QuadTree into a list