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
|
-- |Compute all steps of the graham scan algorithm to allow
|
||||||
-- visualizing it.
|
-- visualizing it.
|
||||||
-- Whether the upper or lower hull is computed depends on the input.
|
-- Whether the upper or lower hull is computed depends on the input.
|
||||||
grahamGetCHSteps :: Int -> [PT] -> [PT] -> [[PT]]
|
grahamCHSteps :: Int -> [PT] -> [PT] -> [[PT]]
|
||||||
grahamGetCHSteps c xs' ys'
|
grahamCHSteps c xs' ys'
|
||||||
| c >= 0 = scanH 0 xs' ys' : grahamGetCHSteps (c - 1) xs' ys'
|
| c >= 0 = scanH 0 xs' ys' : grahamCHSteps (c - 1) xs' ys'
|
||||||
| otherwise = []
|
| otherwise = []
|
||||||
where
|
where
|
||||||
scanH c' hs@(x:y:z:xs) (r':rs')
|
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.
|
-- |Get all iterations of the upper hull of the graham scan algorithm.
|
||||||
grahamGetUpperHullSteps :: [PT] -> [[PT]]
|
grahamUHSteps :: [PT] -> [[PT]]
|
||||||
grahamGetUpperHullSteps vs =
|
grahamUHSteps vs =
|
||||||
(++) [getLastX 2 sortedXY] .
|
(++) [getLastX 2 sortedXY] .
|
||||||
rmdups .
|
rmdups .
|
||||||
init .
|
init .
|
||||||
reverse .
|
reverse .
|
||||||
grahamGetCHSteps ((* 2) . length $ vs) uH $
|
grahamCHSteps ((* 2) . length $ vs) uH $
|
||||||
uHRest
|
uHRest
|
||||||
where
|
where
|
||||||
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
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.
|
-- |Get all iterations of the lower hull of the graham scan algorithm.
|
||||||
grahamGetLowerHullSteps :: [PT] -> [[PT]]
|
grahamLHSteps :: [PT] -> [[PT]]
|
||||||
grahamGetLowerHullSteps vs =
|
grahamLHSteps vs =
|
||||||
(++) [take 2 sortedXY] .
|
(++) [take 2 sortedXY] .
|
||||||
rmdups .
|
rmdups .
|
||||||
reverse .
|
reverse .
|
||||||
grahamGetCHSteps ((* 2) . length $ vs) lH $
|
grahamCHSteps ((* 2) . length $ vs) lH $
|
||||||
lHRest
|
lHRest
|
||||||
where
|
where
|
||||||
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
||||||
|
@ -87,7 +87,7 @@ convexHullLines = Diag chl
|
|||||||
|
|
||||||
convexHullLinesIntervalLower :: DiagProp -> [PT] -> [Diagram Cairo R2]
|
convexHullLinesIntervalLower :: DiagProp -> [PT] -> [Diagram Cairo R2]
|
||||||
convexHullLinesIntervalLower p xs =
|
convexHullLinesIntervalLower p xs =
|
||||||
fmap mkChDiag (grahamGetLowerHullSteps xs)
|
fmap mkChDiag (grahamLHSteps xs)
|
||||||
where
|
where
|
||||||
mkChDiag vt =
|
mkChDiag vt =
|
||||||
(strokeTrail .
|
(strokeTrail .
|
||||||
@ -101,7 +101,7 @@ convexHullLinesIntervalLower p xs =
|
|||||||
|
|
||||||
convexHullLinesIntervalUpper :: DiagProp -> [PT] -> [Diagram Cairo R2]
|
convexHullLinesIntervalUpper :: DiagProp -> [PT] -> [Diagram Cairo R2]
|
||||||
convexHullLinesIntervalUpper p xs =
|
convexHullLinesIntervalUpper p xs =
|
||||||
fmap mkChDiag (grahamGetUpperHullSteps xs)
|
fmap mkChDiag (grahamUHSteps xs)
|
||||||
where
|
where
|
||||||
mkChDiag vt =
|
mkChDiag vt =
|
||||||
(strokeTrail .
|
(strokeTrail .
|
||||||
|
Loading…
Reference in New Issue
Block a user