hgeometry-0.12.0.4: Geometric Algorithms, Data structures, and Data types.

Description

Synopsis

Documentation

type WidthIndex = Int Source #

side lengths will be 2^i for some integer i

data Cell r Source #

A Cell corresponding to a node in the QuadTree

Constructors

 Cell Fields_cellWidthIndex :: !WidthIndex _lowerLeft :: !(Point 2 r)

Instances

Instances details

lowerLeft :: forall r r. Lens (Cell r) (Cell r) (Point 2 r) (Point 2 r) Source #

fitsRectangle :: (RealFrac r, Ord r) => Rectangle p r -> Cell r Source #

Computes a cell that contains the given rectangle

toBox :: Fractional r => Cell r -> Box 2 () r Source #

inCell :: (Fractional r, Ord r) => (Point 2 r :+ p) -> Cell r -> Bool 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


relationTo :: (Fractional r, Ord r) => (p :+ Cell r) -> Cell r -> Sides (Maybe (p :+ Cell r)) Source #

Given two cells c and me, compute on which side of me the cell c is.

pre: c and me are non-overlapping