DIAG: improve function naming and return value in kdSquares
This commit is contained in:
parent
3b61d21549
commit
fd4f135efa
@ -188,25 +188,27 @@ kdSquares = Diag f
|
|||||||
f _ (Object []) = mempty
|
f _ (Object []) = mempty
|
||||||
f p (Object vt) =
|
f p (Object vt) =
|
||||||
mconcat
|
mconcat
|
||||||
. fmap fromVertices
|
. fmap (uncurry (~~))
|
||||||
$ drawAll (kdTree vt Horizontal) (xDimension p, yDimension p)
|
$ kdLines (kdTree vt Horizontal) (xDimension p, yDimension p)
|
||||||
where
|
where
|
||||||
drawAll :: KDTree PT -> Square -> [[PT]]
|
-- Gets all lines that make up the kdSquares. Every line is
|
||||||
drawAll (KTNode ln pt Horizontal rn) ((xmin, xmax), (ymin, ymax)) =
|
-- described by two points, start and end respectively.
|
||||||
(\(x, _) -> [[p2 (x, ymin), p2 (x, ymax)]])
|
kdLines :: KDTree PT -> Square -> [(PT, PT)]
|
||||||
|
kdLines (KTNode ln pt Horizontal rn) ((xmin, xmax), (ymin, ymax)) =
|
||||||
|
(\(x, _) -> [(p2 (x, ymin), p2 (x, ymax))])
|
||||||
(unp2 pt)
|
(unp2 pt)
|
||||||
++ drawAll ln ((xmin, x'), (ymin, ymax))
|
++ kdLines ln ((xmin, x'), (ymin, ymax))
|
||||||
++ drawAll rn ((x', xmax), (ymin, ymax))
|
++ kdLines rn ((x', xmax), (ymin, ymax))
|
||||||
where
|
where
|
||||||
(x', _) = unp2 pt
|
(x', _) = unp2 pt
|
||||||
drawAll (KTNode ln pt Vertical rn) ((xmin, xmax), (ymin, ymax)) =
|
kdLines (KTNode ln pt Vertical rn) ((xmin, xmax), (ymin, ymax)) =
|
||||||
(\(_, y) -> [[p2 (xmin, y), p2 (xmax, y)]])
|
(\(_, y) -> [(p2 (xmin, y), p2 (xmax, y))])
|
||||||
(unp2 pt)
|
(unp2 pt)
|
||||||
++ drawAll ln ((xmin, xmax), (ymin, y'))
|
++ kdLines ln ((xmin, xmax), (ymin, y'))
|
||||||
++ drawAll rn ((xmin, xmax), (y', ymax))
|
++ kdLines rn ((xmin, xmax), (y', ymax))
|
||||||
where
|
where
|
||||||
(_, y') = unp2 pt
|
(_, y') = unp2 pt
|
||||||
drawAll _ _ = [[]]
|
kdLines _ _ = []
|
||||||
f _ _ = mempty
|
f _ _ = mempty
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user