Move toward indexed external placements

This commit is contained in:
2021-11-15 19:36:31 +00:00
parent 59dc24aff6
commit a7f2b5f3ea
9 changed files with 63 additions and 32 deletions
+10 -1
View File
@@ -22,6 +22,7 @@ import Geometry.Intersect
import Geometry.Bezier
import Geometry.Vector
import Geometry.LHS
import Geometry.ConvexPoly
import Data.Maybe
import Data.List
@@ -132,7 +133,8 @@ orderAroundFirst (a:as) = a : orderPolygonAround a as
-- | Reorder points to be anticlockwise around their center.
orderPolygon :: [Point2] -> [Point2]
orderPolygon [] = []
orderPolygon ps = orderPolygonAround (1/ fromIntegral (length ps) *.* foldr1 (+.+) ps) ps
--orderPolygon ps = orderPolygonAround (1/ fromIntegral (length ps) *.* foldr1 (+.+) ps) ps
orderPolygon ps = orderPolygonAround (centroid ps) ps
-- | Adds a point to a convex polygon.
-- If the point is inside, returns the original.
-- Points ordered anticlockwise, input not checked.
@@ -447,6 +449,13 @@ arcStepwisePositive ssize a cen v = (cen +.+) . (`rotateV` v) <$> rots
n :: Int
n = ceiling (a * magV v / ssize)
-- | Given a list of points, returns pairs of points linking the points into a
-- loop.
chainPairs :: [Point2] -> [(Point2,Point2)]
chainPairs [] = error "tried to make chain with empty list of points"
chainPairs [_] = error "tried to make chain with singleton list of points"
chainPairs xs = zip xs $ tail xs
-- | Given a list of points, returns pairs of points linking the points into a
-- loop.
loopPairs :: [Point2] -> [(Point2,Point2)]