ALGO: improve function names
This commit is contained in:
parent
7cdb867cf4
commit
edde93ec77
@ -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
|
||||
|
@ -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 .
|
||||
|
Loading…
Reference in New Issue
Block a user