Improve prettiness further
This commit is contained in:
parent
9c7acc6dce
commit
62583d82a5
@ -82,13 +82,13 @@ grahamCH vs = grahamUCH vs ++ (tailInit . grahamLCH $ vs)
|
|||||||
-- |Get the lower part of the convex hull.
|
-- |Get the lower part of the convex hull.
|
||||||
grahamLCH :: [PT] -> [PT]
|
grahamLCH :: [PT] -> [PT]
|
||||||
grahamLCH vs = uncurry (\x y -> last . scanH x $ y)
|
grahamLCH vs = uncurry (\x y -> last . scanH x $ y)
|
||||||
(first reverse . splitAt 3 . sortedXY $ vs)
|
(first reverse . splitAt 3 . sortedXY $ vs)
|
||||||
|
|
||||||
|
|
||||||
-- |Get the upper part of the convex hull.
|
-- |Get the upper part of the convex hull.
|
||||||
grahamUCH :: [PT] -> [PT]
|
grahamUCH :: [PT] -> [PT]
|
||||||
grahamUCH vs = uncurry (\x y -> last . scanH x $ y)
|
grahamUCH vs = uncurry (\x y -> last . scanH x $ y)
|
||||||
(first reverse . splitAt 3 . reverse . sortedXY $ vs)
|
(first reverse . splitAt 3 . reverse . sortedXY $ vs)
|
||||||
|
|
||||||
|
|
||||||
-- |This scans only a half of the convex hull, but all steps (the last
|
-- |This scans only a half of the convex hull, but all steps (the last
|
||||||
@ -119,10 +119,10 @@ grahamCHSteps c xs' ys' = take c . scanH 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.
|
||||||
grahamUHSteps :: [PT] -> [[PT]]
|
grahamUHSteps :: [PT] -> [[PT]]
|
||||||
grahamUHSteps vs =
|
grahamUHSteps vs =
|
||||||
(++) [getLastX 2 . sortedXY $ vs] .
|
(++) [getLastX 2 . sortedXY $ vs]
|
||||||
rmdups .
|
. rmdups
|
||||||
grahamCHSteps ((* 2) . length $ vs) uH $
|
. grahamCHSteps ((* 2) . length $ vs) uH
|
||||||
uHRest
|
$ uHRest
|
||||||
where
|
where
|
||||||
(uH, uHRest) = first reverse . splitAt 3 . reverse . sortedXY $ vs
|
(uH, uHRest) = first reverse . splitAt 3 . reverse . sortedXY $ vs
|
||||||
|
|
||||||
@ -130,9 +130,9 @@ grahamUHSteps 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.
|
||||||
grahamLHSteps :: [PT] -> [[PT]]
|
grahamLHSteps :: [PT] -> [[PT]]
|
||||||
grahamLHSteps vs =
|
grahamLHSteps vs =
|
||||||
(++) [take 2 . sortedXY $ vs] .
|
(++) [take 2 . sortedXY $ vs]
|
||||||
rmdups .
|
. rmdups
|
||||||
grahamCHSteps ((* 2) . length $ vs) lH $
|
. grahamCHSteps ((* 2) . length $ vs) lH
|
||||||
lHRest
|
$ lHRest
|
||||||
where
|
where
|
||||||
(lH, lHRest) = first reverse . splitAt 3 . sortedXY $ vs
|
(lH, lHRest) = first reverse . splitAt 3 . sortedXY $ vs
|
||||||
|
@ -127,8 +127,8 @@ intersectionPoints xs' = rmdups . go $ xs'
|
|||||||
segIntersections :: ([Segment], [Segment]) -> [PT]
|
segIntersections :: ([Segment], [Segment]) -> [PT]
|
||||||
segIntersections (a@(_:_), b@(_:_)) =
|
segIntersections (a@(_:_), b@(_:_)) =
|
||||||
catMaybes
|
catMaybes
|
||||||
. fmap (\[x, y] -> intersectSeg' x y)
|
. fmap (\[x, y] -> intersectSeg' x y)
|
||||||
$ combinations a b
|
$ combinations a b
|
||||||
segIntersections _ = []
|
segIntersections _ = []
|
||||||
|
|
||||||
-- Gets all unique(!) combinations of two arrays. Both arrays
|
-- Gets all unique(!) combinations of two arrays. Both arrays
|
||||||
|
Loading…
Reference in New Issue
Block a user