Improve redability, add docs
This commit is contained in:
parent
87393af71a
commit
2c1d5fa5ec
@ -122,21 +122,28 @@ grahamGetCHSteps c xs' ys'
|
|||||||
scanH _ xs _ = xs
|
scanH _ xs _ = xs
|
||||||
|
|
||||||
|
|
||||||
|
-- |Get all iterations of the upper hull of the graham scan algorithm.
|
||||||
grahamGetUpperHullSteps :: [PT] -> [[PT]]
|
grahamGetUpperHullSteps :: [PT] -> [[PT]]
|
||||||
grahamGetUpperHullSteps vs =
|
grahamGetUpperHullSteps vs =
|
||||||
(++) [getLastX 2 sortedXY] . rmdups . init . reverse . grahamGetCHSteps ((* 2) . length $ vs) uH $
|
(++) [getLastX 2 sortedXY] .
|
||||||
|
rmdups .
|
||||||
|
init .
|
||||||
|
reverse .
|
||||||
|
grahamGetCHSteps ((* 2) . length $ vs) uH $
|
||||||
uHRest
|
uHRest
|
||||||
where
|
where
|
||||||
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
||||||
(uH, uHRest) = first reverse . splitAt 3 . reverse $ sortedXY
|
(uH, uHRest) = first reverse . splitAt 3 . reverse $ sortedXY
|
||||||
|
|
||||||
|
|
||||||
|
-- |Get all iterations of the lower hull of the graham scan algorithm.
|
||||||
grahamGetLowerHullSteps :: [PT] -> [[PT]]
|
grahamGetLowerHullSteps :: [PT] -> [[PT]]
|
||||||
grahamGetLowerHullSteps vs =
|
grahamGetLowerHullSteps vs =
|
||||||
(++) [take 2 sortedXY] . rmdups . reverse . grahamGetCHSteps ((* 2) . length $ vs) lH $ lHRest
|
(++) [take 2 sortedXY] .
|
||||||
|
rmdups .
|
||||||
|
reverse .
|
||||||
|
grahamGetCHSteps ((* 2) . length $ vs) lH $
|
||||||
|
lHRest
|
||||||
where
|
where
|
||||||
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
||||||
(lH, lHRest) = first reverse . splitAt 3 $ sortedXY
|
(lH, lHRest) = first reverse . splitAt 3 $ sortedXY
|
||||||
|
|
||||||
{- - (++) (rmdups . reverse . g ((* 2) . length $ vs) lH $ lHRest) -}
|
|
||||||
{- - (rmdups . init . reverse . g ((* 2) . length $ vs) uH $ uHRest) -}
|
|
||||||
|
@ -20,9 +20,7 @@ gifDiag p xs =
|
|||||||
[mkDiag (convexHullPointsText `mappend`
|
[mkDiag (convexHullPointsText `mappend`
|
||||||
convexHullPoints)
|
convexHullPoints)
|
||||||
p xs <> lastUpperHull <> lastLowerHull] $
|
p xs <> lastUpperHull <> lastLowerHull] $
|
||||||
(lowerHullList ++
|
(lowerHullList ++ ((<> lastLowerHull) <$> upperHullList))
|
||||||
((<> lastLowerHull) <$>
|
|
||||||
upperHullList))
|
|
||||||
where
|
where
|
||||||
upperHullList = convexHullLinesIntervalUpper p xs
|
upperHullList = convexHullLinesIntervalUpper p xs
|
||||||
lastUpperHull = last upperHullList
|
lastUpperHull = last upperHullList
|
||||||
|
Loading…
Reference in New Issue
Block a user