Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- type WidthIndex = Int
- data Cell r = Cell {
- _cellWidthIndex :: !WidthIndex
- _lowerLeft :: !(Point 2 r)
- lowerLeft :: forall r r. Lens (Cell r) (Cell r) (Point 2 r) (Point 2 r)
- cellWidthIndex :: forall r. Lens' (Cell r) WidthIndex
- fitsRectangle :: (RealFrac r, Ord r) => Rectangle p r -> Cell r
- pow :: Fractional r => WidthIndex -> r
- cellWidth :: Fractional r => Cell r -> r
- toBox :: Fractional r => Cell r -> Box 2 () r
- inCell :: (Fractional r, Ord r) => (Point 2 r :+ p) -> Cell r -> Bool
- cellCorners :: Fractional r => Cell r -> Quadrants (Point 2 r)
- cellSides :: Fractional r => Cell r -> Sides (LineSegment 2 () r)
- splitCell :: (Num r, Fractional r) => Cell r -> Quadrants (Cell r)
- midPoint :: Fractional r => Cell r -> Point 2 r
- partitionPoints :: (Fractional r, Ord r) => Cell r -> [Point 2 r :+ p] -> Quadrants [Point 2 r :+ p]
- quadrantOf :: forall r. (Fractional r, Ord r) => Point 2 r -> Cell r -> InterCardinalDirection
- relationTo :: (Fractional r, Ord r) => (p :+ Cell r) -> Cell r -> Sides (Maybe (p :+ Cell r))
Documentation
type WidthIndex = Int Source #
side lengths will be 2^i for some integer i
A Cell corresponding to a node in the QuadTree
Cell | |
|
Instances
cellWidthIndex :: forall r. Lens' (Cell r) WidthIndex Source #
fitsRectangle :: (RealFrac r, Ord r) => Rectangle p r -> Cell r Source #
Computes a cell that contains the given rectangle
pow :: Fractional r => WidthIndex -> r Source #
cellWidth :: Fractional r => Cell r -> r Source #
cellCorners :: Fractional r => Cell r -> Quadrants (Point 2 r) Source #
cellSides :: Fractional r => Cell r -> Sides (LineSegment 2 () r) Source #
Sides are open
partitionPoints :: (Fractional r, Ord r) => Cell r -> [Point 2 r :+ p] -> Quadrants [Point 2 r :+ p] Source #
Partitions the points into quadrants. See quadrantOf
for the
precise rules.
quadrantOf :: forall r. (Fractional r, Ord r) => Point 2 r -> Cell r -> InterCardinalDirection Source #
Computes the quadrant of the cell corresponding to the current point. Note that we decide the quadrant solely based on the midpoint. If the query point lies outside the cell, it is still assigned a quadrant.
- The northEast quadrants includes its bottom and left side
- The southEast quadrant includes its left side
- The northWest quadrant includes its bottom side
- The southWest quadrants does not include any of its sides.
>>>
quadrantOf (Point2 9 9) (Cell 4 origin)
NorthEast>>>
quadrantOf (Point2 8 9) (Cell 4 origin)
NorthEast>>>
quadrantOf (Point2 8 8) (Cell 4 origin)
NorthEast>>>
quadrantOf (Point2 8 7) (Cell 4 origin)
SouthEast>>>
quadrantOf (Point2 4 7) (Cell 4 origin)
SouthWest>>>
quadrantOf (Point2 4 10) (Cell 4 origin)
NorthWest>>>
quadrantOf (Point2 4 40) (Cell 4 origin)
NorthEast>>>
quadrantOf (Point2 4 40) (Cell 4 origin)
NorthWest