Move towards unifying zoning

This commit is contained in:
2022-10-28 13:14:53 +01:00
parent 7e790b7153
commit d3233c7daa
6 changed files with 36 additions and 11 deletions
+4 -3
View File
@@ -8,10 +8,10 @@ import Geometry.Zone
import qualified IntMapHelp as IM
zoneOfCirc :: Float -> Point2 -> Float -> [Int2]
zoneOfCirc zsize p r = zoneOfRect' zsize (p +.+ V2 r r) (p -.- V2 r r)
zoneOfCirc zsize p r = zoneOfRect zsize (p +.+ V2 r r) (p -.- V2 r r)
zoneOfRect' :: Float -> Point2 -> Point2 -> [Int2]
zoneOfRect' s sp ep = [V2 x y | x <- makeIntInterval sx ex, y <- makeIntInterval sy ey]
zoneOfRect :: Float -> Point2 -> Point2 -> [Int2]
zoneOfRect s sp ep = [V2 x y | x <- makeIntInterval sx ex, y <- makeIntInterval sy ey]
where
V2 sx sy = zoneOfPoint s sp
V2 ex ey = zoneOfPoint s ep
@@ -33,6 +33,7 @@ zoneOfSeg :: Float -> Point2 -> Point2 -> [Int2]
zoneOfSeg s sp ep = map (zoneOfPoint s) (sp : xIntercepts s sp ep ++ yIntercepts' s sp ep)
zoneExtract :: Monoid m => Int2 -> IM.IntMap (IM.IntMap m) -> m
{-# INLINE zoneExtract #-}
zoneExtract (V2 x y) = fromMaybe mempty . (^? ix x . ix y)
zonesExtract :: Monoid m => IM.IntMap (IM.IntMap m) -> [Int2] -> m