From edde93ec77e22db9c38954be0f43c1f419b2c0ae Mon Sep 17 00:00:00 2001 From: hasufell Date: Mon, 13 Oct 2014 19:50:02 +0200 Subject: [PATCH] ALGO: improve function names --- Algorithms/ConvexHull/GrahamScan.hs | 18 +++++++++--------- Graphics/Diagram/Plotter.hs | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Algorithms/ConvexHull/GrahamScan.hs b/Algorithms/ConvexHull/GrahamScan.hs index 856b354..0731159 100644 --- a/Algorithms/ConvexHull/GrahamScan.hs +++ b/Algorithms/ConvexHull/GrahamScan.hs @@ -116,9 +116,9 @@ scanH hs _ = hs -- |Compute all steps of the graham scan algorithm to allow -- visualizing it. -- Whether the upper or lower hull is computed depends on the input. -grahamGetCHSteps :: Int -> [PT] -> [PT] -> [[PT]] -grahamGetCHSteps c xs' ys' - | c >= 0 = scanH 0 xs' ys' : grahamGetCHSteps (c - 1) xs' ys' +grahamCHSteps :: Int -> [PT] -> [PT] -> [[PT]] +grahamCHSteps c xs' ys' + | c >= 0 = scanH 0 xs' ys' : grahamCHSteps (c - 1) xs' ys' | otherwise = [] where scanH c' hs@(x:y:z:xs) (r':rs') @@ -136,13 +136,13 @@ grahamGetCHSteps c xs' ys' -- |Get all iterations of the upper hull of the graham scan algorithm. -grahamGetUpperHullSteps :: [PT] -> [[PT]] -grahamGetUpperHullSteps vs = +grahamUHSteps :: [PT] -> [[PT]] +grahamUHSteps vs = (++) [getLastX 2 sortedXY] . rmdups . init . reverse . - grahamGetCHSteps ((* 2) . length $ vs) uH $ + grahamCHSteps ((* 2) . length $ vs) uH $ uHRest where sortedXY = fmap p2 . sortLex . fmap unp2 $ vs @@ -150,12 +150,12 @@ grahamGetUpperHullSteps vs = -- |Get all iterations of the lower hull of the graham scan algorithm. -grahamGetLowerHullSteps :: [PT] -> [[PT]] -grahamGetLowerHullSteps vs = +grahamLHSteps :: [PT] -> [[PT]] +grahamLHSteps vs = (++) [take 2 sortedXY] . rmdups . reverse . - grahamGetCHSteps ((* 2) . length $ vs) lH $ + grahamCHSteps ((* 2) . length $ vs) lH $ lHRest where sortedXY = fmap p2 . sortLex . fmap unp2 $ vs diff --git a/Graphics/Diagram/Plotter.hs b/Graphics/Diagram/Plotter.hs index b3f4c92..1062e20 100644 --- a/Graphics/Diagram/Plotter.hs +++ b/Graphics/Diagram/Plotter.hs @@ -87,7 +87,7 @@ convexHullLines = Diag chl convexHullLinesIntervalLower :: DiagProp -> [PT] -> [Diagram Cairo R2] convexHullLinesIntervalLower p xs = - fmap mkChDiag (grahamGetLowerHullSteps xs) + fmap mkChDiag (grahamLHSteps xs) where mkChDiag vt = (strokeTrail . @@ -101,7 +101,7 @@ convexHullLinesIntervalLower p xs = convexHullLinesIntervalUpper :: DiagProp -> [PT] -> [Diagram Cairo R2] convexHullLinesIntervalUpper p xs = - fmap mkChDiag (grahamGetUpperHullSteps xs) + fmap mkChDiag (grahamUHSteps xs) where mkChDiag vt = (strokeTrail .