Improve redability, add docs
This commit is contained in:
parent
87393af71a
commit
2c1d5fa5ec
@ -122,21 +122,28 @@ grahamGetCHSteps c xs' ys'
|
||||
scanH _ xs _ = xs
|
||||
|
||||
|
||||
-- |Get all iterations of the upper hull of the graham scan algorithm.
|
||||
grahamGetUpperHullSteps :: [PT] -> [[PT]]
|
||||
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
|
||||
where
|
||||
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
||||
(uH, uHRest) = first reverse . splitAt 3 . reverse $ sortedXY
|
||||
|
||||
|
||||
-- |Get all iterations of the lower hull of the graham scan algorithm.
|
||||
grahamGetLowerHullSteps :: [PT] -> [[PT]]
|
||||
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
|
||||
sortedXY = fmap p2 . sortLex . fmap unp2 $ vs
|
||||
(lH, lHRest) = first reverse . splitAt 3 $ sortedXY
|
||||
|
||||
{- - (++) (rmdups . reverse . g ((* 2) . length $ vs) lH $ lHRest) -}
|
||||
{- - (rmdups . init . reverse . g ((* 2) . length $ vs) uH $ uHRest) -}
|
||||
|
@ -14,15 +14,13 @@ import Parser.Meshparser
|
||||
-- |Return a list of tuples used by 'gifMain' to generate an animated gif.
|
||||
gifDiag :: DiagProp -> [PT] -> [(Diagram Cairo R2, GifDelay)]
|
||||
gifDiag p xs =
|
||||
fmap (\x -> (x, 100)) .
|
||||
fmap (\x -> x <> nonChDiag) .
|
||||
fmap (\x -> (x, 100)) .
|
||||
fmap (\x -> x <> nonChDiag) .
|
||||
flip (++)
|
||||
[mkDiag (convexHullPointsText `mappend`
|
||||
convexHullPoints)
|
||||
p xs <> lastUpperHull <> lastLowerHull] $
|
||||
(lowerHullList ++
|
||||
((<> lastLowerHull) <$>
|
||||
upperHullList))
|
||||
convexHullPoints)
|
||||
p xs <> lastUpperHull <> lastLowerHull] $
|
||||
(lowerHullList ++ ((<> lastLowerHull) <$> upperHullList))
|
||||
where
|
||||
upperHullList = convexHullLinesIntervalUpper p xs
|
||||
lastUpperHull = last upperHullList
|
||||
|
Loading…
Reference in New Issue
Block a user