QuadTree implementation in Elm.
Construct an empty QuadTree given a bounding box and a maxSize. The maxSize limits the number of elements that each leaf of the QuadTree can hold.
Extend this record type in order to use the QuadTree.
Find the number of items in a quadTree. If elements are duplicated in different leaves, they will be counted multiple times.
Get the maxSize of a quadTree.
Get the bounding box of a quadTree.
Insert an item into a quadTree.
Remove an item from a quadTree and return the new quadTree. If an item is found in multiple leaves, then the item will be removed from all leaves.
Update an item in a quadTree. This is useful if you just want to update a single item. This removes the item from the quadTree, applies the given updateFunction, and then inserts the updated item into the quadTree.
Find all items in the quadTree which share a leaf with the given item or would share a leaf with the given item were the item in the quadTree. Useful for finding items close to the given item.
Find all items that actually intersect with the given item.
Similar to findItems but will return only intersection items, without neighboring items.
Find all the neighbors that are within a particular distance from an input object.
Apply a function, that takes an item and an array of items and returns an item, to a quadTree. This function is a useful helper for collision detection and response where the input function updates an object after colliding it with an array of objects.
Safe version of apply. Automatically calls reset after applying the function on the quadTree.
The good 'ol map function.
Maps a function over a quadTree and returns a new quadTree.
Note: If your function modifies in any way the items'
bounding boxes, consider using mapSafe or calling reset
after you are done as the quadTree may have items in the
wrong place. This function doesn't do the clean-up
automatically. If you want such functionality, use mapSafe.
Version of map where the quadTree is reset
automatically after applying the function.
Reset a quadTree. This function gets all items in a quadTree and pours them into an empty quadTree. Useful if the items in the quadTree find themselves in the wrong leaves.
QuadTree type. Keeps its elements in the leaves and keeps track of the maximum number of items that can be inserted in each leaf.