Work on chasm rooms
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user