DIAGRAM: fix drawing for negative coordinates

Applying the filter function too late seemed to cause
glitches in convexHStepsLs for negative coordinates.
We should only pass the filtered list of points to
the graham scan.
This commit is contained in:
hasufell 2014-10-14 10:56:06 +02:00
parent 873af1cfec
commit 0379463db4
1 changed files with 6 additions and 7 deletions

View File

@ -48,11 +48,11 @@ convexHP :: Diag
convexHP = Diag chp convexHP = Diag chp
where where
chp p vt = chp p vt =
position (zip (filter (inRange (dX p) (dY p)) vtch) position (zip vtch
(repeat dot)) (repeat dot))
where where
dot = (circle $ t p :: Diagram Cairo R2) # fc red # lc red dot = (circle $ t p :: Diagram Cairo R2) # fc red # lc red
vtch = grahamCH vt vtch = grahamCH $ filter (inRange (dX p) (dY p)) vt
-- |Show coordinates as text above the convex hull points. -- |Show coordinates as text above the convex hull points.
@ -94,16 +94,15 @@ convexHStepsLs :: Colour Double
-> [PT] -> [PT]
-> [Diagram Cairo R2] -> [Diagram Cairo R2]
convexHStepsLs col f p xs = convexHStepsLs col f p xs =
fmap mkChDiag (f xs) fmap mkChDiag (f xs')
where where
xs' = filter (inRange (dX p) (dY p)) xs
mkChDiag vt = mkChDiag vt =
(strokeTrail . (strokeTrail .
fromVertices $ fromVertices $
vtf) # vt) #
moveTo (head vtf) # moveTo (head vt) #
lc col lc col
where
vtf = filter (inRange (dX p) (dY p)) vt
-- |Create list of diagrama which describe the lines along the lower -- |Create list of diagrama which describe the lines along the lower