KdTree-0.2.2.1: KdTree, for efficient search in K-dimensional point clouds.

Safe HaskellSafe
LanguageHaskell2010

Data.Trees.KdTree

Synopsis

Documentation

class Point p where Source #

Minimal complete definition

dimension, coord

Methods

dimension :: p -> Int Source #

dimension returns the number of coordinates of a point.

coord :: Int -> p -> Double Source #

coord gets the k'th coordinate, starting from 0.

dist2 :: p -> p -> Double Source #

dist2 returns the squared distance between two points.

compareDistance :: Point p => p -> p -> p -> Ordering Source #

compareDistance p a b compares the distances of a and b to p.

data KdTree point Source #

Constructors

KdNode 

Fields

KdEmpty 

Instances

Functor KdTree Source # 

Methods

fmap :: (a -> b) -> KdTree a -> KdTree b #

(<$) :: a -> KdTree b -> KdTree a #

Foldable KdTree Source # 

Methods

fold :: Monoid m => KdTree m -> m #

foldMap :: Monoid m => (a -> m) -> KdTree a -> m #

foldr :: (a -> b -> b) -> b -> KdTree a -> b #

foldr' :: (a -> b -> b) -> b -> KdTree a -> b #

foldl :: (b -> a -> b) -> b -> KdTree a -> b #

foldl' :: (b -> a -> b) -> b -> KdTree a -> b #

foldr1 :: (a -> a -> a) -> KdTree a -> a #

foldl1 :: (a -> a -> a) -> KdTree a -> a #

toList :: KdTree a -> [a] #

null :: KdTree a -> Bool #

length :: KdTree a -> Int #

elem :: Eq a => a -> KdTree a -> Bool #

maximum :: Ord a => KdTree a -> a #

minimum :: Ord a => KdTree a -> a #

sum :: Num a => KdTree a -> a #

product :: Num a => KdTree a -> a #

Eq point => Eq (KdTree point) Source # 

Methods

(==) :: KdTree point -> KdTree point -> Bool #

(/=) :: KdTree point -> KdTree point -> Bool #

Ord point => Ord (KdTree point) Source # 

Methods

compare :: KdTree point -> KdTree point -> Ordering #

(<) :: KdTree point -> KdTree point -> Bool #

(<=) :: KdTree point -> KdTree point -> Bool #

(>) :: KdTree point -> KdTree point -> Bool #

(>=) :: KdTree point -> KdTree point -> Bool #

max :: KdTree point -> KdTree point -> KdTree point #

min :: KdTree point -> KdTree point -> KdTree point #

Show point => Show (KdTree point) Source # 

Methods

showsPrec :: Int -> KdTree point -> ShowS #

show :: KdTree point -> String #

showList :: [KdTree point] -> ShowS #

fromList :: Point p => [p] -> KdTree p Source #

fromListWithDepth :: Point p => [p] -> Int -> KdTree p Source #

fromListWithDepth selects an axis based on depth so that the axis cycles through all valid values.

toList :: KdTree p -> [p] Source #

subtrees :: KdTree p -> [KdTree p] Source #

subtrees t returns a list containing t and all its subtrees, including the empty leaf nodes.

nearestNeighbor :: Point p => KdTree p -> p -> Maybe p Source #

nearestNeighbor tree p returns the nearest neighbor of p in tree.

nearNeighbors :: Point p => KdTree p -> Double -> p -> [p] Source #

nearNeighbors tree p returns all neighbors within distance r from p in tree.

isValid :: Point p => KdTree p -> Bool Source #

isValid tells whether the K-D tree property holds for a given tree. Specifically, it tests that all points in the left subtree lie to the left of the plane, p is on the plane, and all points in the right subtree lie to the right.

allSubtreesAreValid :: Point p => KdTree p -> Bool Source #

allSubtreesAreValid tells whether the K-D tree property holds for the given tree and all subtrees.

kNearestNeighbors :: (Eq p, Point p) => KdTree p -> Int -> p -> [p] Source #

kNearestNeighbors tree k p returns the k closest points to p within tree.

remove :: (Eq p, Point p) => KdTree p -> p -> KdTree p Source #

remove t p removes the point p from t.