DIAGRAM: fix filtering of points based on the dimensions

This commit is contained in:
hasufell 2014-10-09 18:51:32 +02:00
parent de5aba792e
commit e2f1c865f3
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020

View File

@ -116,27 +116,31 @@ convexHullLines :: Diag
convexHullLines = Diag f convexHullLines = Diag f
where where
f _ [] = mempty f _ [] = mempty
f _ vt f p vt
= (strokeTrail . = (strokeTrail .
fromVertices . fromVertices .
flip (++) [head $ grahamGetCH vt] . flip (++) [head $ grahamGetCH vtf] .
grahamGetCH $ grahamGetCH $
vt vtf
) # moveTo (head $ grahamGetCH vt) # lc red ) # moveTo (head $ grahamGetCH vtf) # lc red
where
vtf = filter (inRange (dX p) (dY p)) vt
-- |Same as showConvexHullLines, except that it returns an array -- |Same as showConvexHullLines, except that it returns an array
-- of diagrams with each step of the algorithm. -- of diagrams with each step of the algorithm.
-- Unfortunately this is very difficult to implement as a Diag (TODO). -- Unfortunately this is very difficult to implement as a Diag (TODO).
convexHullLinesInterval :: DiagProp -> [PT] -> [Diagram Cairo R2] convexHullLinesInterval :: DiagProp -> [PT] -> [Diagram Cairo R2]
convexHullLinesInterval _ xs = convexHullLinesInterval p xs =
fmap g (grahamGetCHSteps xs) fmap g (grahamGetCHSteps xs)
where where
g vt g vt
= (strokeTrail . = (strokeTrail .
fromVertices $ fromVertices $
vt vtf
) # moveTo (head vt) # lc red ) # moveTo (head vtf) # lc red
where
vtf = filter (inRange (dX p) (dY p)) vt
-- |Creates a Diagram that shows an XAxis which is bound -- |Creates a Diagram that shows an XAxis which is bound