HGE2D-0.1.9.0: 2D game engine written in Haskell

Copyright(c) 2016 Martin Buck
Licensesee LICENSE
Safe HaskellNone
LanguageHaskell2010

HGE2D.QuadTree

Description

Containing the definition and functions for a quad tree

Synopsis

Documentation

data Positioned a => QuadTree a Source #

A QuadTree for faster search queries

data QuadDir Source #

Posibble directions within a branch (negative x && negative y | negative x && positive y ...)

Constructors

NN 
NP 
PN 
PP 

fmapQuad :: (Positioned a, Positioned b) => (a -> b) -> QuadTree a -> QuadTree b Source #

Mapping function for the QuadTree. Do not use with functions which change the position of items, since they would invalidate the search structure (use fmapQuadRebuild instead)

fmapQuadRebuild :: (Positioned a, Positioned b) => (a -> b) -> QuadTree a -> QuadTree b Source #

Mapping function for the QuadTree. This rebuilds the entire tree, but allows the usage of position changing functions. Use this only for positioned changing functions, and fmapQuad otherwise, since it is faster

buildQuadTree :: Positioned a => [a] -> QuadTree a Source #

Builds a QuadTree from a list of elements with positions.

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