Make zoning more universal

This commit is contained in:
2022-06-28 19:04:31 +01:00
parent 4965934502
commit b1a7e1bf35
16 changed files with 152 additions and 97 deletions
+10 -1
View File
@@ -11,10 +11,13 @@ module Geometry.Zone
, yIntercepts
, divTo
, zoneOfPoint
, zoneOfSeg
, zoneInsideCirc
) where
import Geometry.Data
import Geometry.Vector
import Streaming
import StreamingHelp
import qualified Streaming.Prelude as S
import Data.Foldable
import qualified Data.IntMap.Strict as IM
@@ -157,6 +160,12 @@ makeInterval x y
| x < y = [x-1..y+1]
| otherwise = [y-1..x+1]
zoneInsideCirc :: Float -> Point2 -> Float -> StreamOf Int2
zoneInsideCirc x p r = ddaSqStream x (p +.+ V2 r r) (p -.- V2 r r)
zoneOfSeg :: Float -> Point2 -> Point2 -> StreamOf Int2
zoneOfSeg = ddaStream
ddaStream :: Float -> Point2 -> Point2 -> Stream (Of (V2 Int)) Identity ()
ddaStream s sp ep = S.map (zoneOfPoint s)
$ S.yield sp