From 0379463db4eb260b514f01d8c99ba29f83f8b20e Mon Sep 17 00:00:00 2001 From: hasufell Date: Tue, 14 Oct 2014 10:56:06 +0200 Subject: [PATCH] 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. --- Graphics/Diagram/Plotter.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Graphics/Diagram/Plotter.hs b/Graphics/Diagram/Plotter.hs index aba42e0..5010abc 100644 --- a/Graphics/Diagram/Plotter.hs +++ b/Graphics/Diagram/Plotter.hs @@ -48,11 +48,11 @@ convexHP :: Diag convexHP = Diag chp where chp p vt = - position (zip (filter (inRange (dX p) (dY p)) vtch) + position (zip vtch (repeat dot)) where 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. @@ -94,16 +94,15 @@ convexHStepsLs :: Colour Double -> [PT] -> [Diagram Cairo R2] convexHStepsLs col f p xs = - fmap mkChDiag (f xs) + fmap mkChDiag (f xs') where + xs' = filter (inRange (dX p) (dY p)) xs mkChDiag vt = (strokeTrail . fromVertices $ - vtf) # - moveTo (head vtf) # + vt) # + moveTo (head vt) # lc col - where - vtf = filter (inRange (dX p) (dY p)) vt -- |Create list of diagrama which describe the lines along the lower