Work on chasm rooms

This commit is contained in:
2025-10-02 16:58:38 +01:00
parent 013f50f0bc
commit 7e3614c9c8
15 changed files with 301 additions and 152 deletions
+18
View File
@@ -2,6 +2,7 @@
module Geometry.Polygon where
import Geometry.Intersect
import qualified Control.Foldl as L
import Data.Maybe
import Geometry.Data
@@ -46,6 +47,23 @@ rectVV (V2 x y) (V2 a b) = rectNSWE n s w e
square :: Float -> [Point2]
square n = rectWH n n
polyOrthDist :: Int -> Float -> [Point2]
polyOrthDist n x = mapMaybe
(\(ra, rb) -> intersectLineLine (rotateV ra bl) (rotateV ra br) (rotateV rb bl) (rotateV rb br))
$ loopPairs rots
where
rot = 2 * pi / fromIntegral n
rots = map ((rot *) . fromIntegral) [0 .. n -1]
bl = V2 x x
br = V2 (- x) x
polyCornerDist :: Int -> Float -> [Point2]
polyCornerDist n x = map f rots
where
rot = 2 * pi / fromIntegral n
rots = map ((rot *) . fromIntegral) [0 .. n -1]
f a = rotateV a (V2 x 0)
mirrorXAxis :: [Point2] -> [Point2]
mirrorXAxis ps = orderPolygon $ ps ++ mapMaybe f ps
where