Improve redability, add docs

This commit is contained in:
hasufell 2014-10-13 03:25:22 +02:00
parent 87393af71a
commit 2c1d5fa5ec
2 changed files with 17 additions and 12 deletions

View File

@ -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) -}

View File

@ -14,15 +14,13 @@ import Parser.Meshparser
-- |Return a list of tuples used by 'gifMain' to generate an animated gif. -- |Return a list of tuples used by 'gifMain' to generate an animated gif.
gifDiag :: DiagProp -> [PT] -> [(Diagram Cairo R2, GifDelay)] gifDiag :: DiagProp -> [PT] -> [(Diagram Cairo R2, GifDelay)]
gifDiag p xs = gifDiag p xs =
fmap (\x -> (x, 100)) . fmap (\x -> (x, 100)) .
fmap (\x -> x <> nonChDiag) . fmap (\x -> x <> nonChDiag) .
flip (++) flip (++)
[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