Refactor wall drawing

This commit is contained in:
2021-03-21 15:38:58 +01:00
parent 6cb87b4d28
commit 1ecbe2375d
3 changed files with 40 additions and 32 deletions
+10
View File
@@ -347,3 +347,13 @@ lineInPolygon a b ps = pointInPolygon a ps || pointInPolygon b ps
|| any (isJust . uncurry (intersectSegSeg' a b)) pss
where pss = zip ps (tail ps ++ [head ps])
makeLoopPairs :: [Point2] -> [(Point2,Point2)]
makeLoopPairs [] = error "tried to make loop with empty list of points"
makeLoopPairs (x:[]) = error "tried to make loop with singleton list of points"
makeLoopPairs (x:xs) = zip (x:xs) (xs ++ [x])
-- note the pair is ordered
-- doesn't work for obtuse angles
pointIsInCone :: Point2 -> (Point2,Point2) -> Point2 -> Bool
pointIsInCone c (rightp,leftp) p = isLHS c rightp p && isLHS leftp c p