Use grid when creating block debris
This commit is contained in:
+10
-1
@@ -3,9 +3,10 @@ module Geometry.Polygon where
|
||||
import Geometry.Data
|
||||
import Geometry.LHS
|
||||
import Geometry.Vector
|
||||
import ListHelp
|
||||
|
||||
import Data.Maybe
|
||||
import Data.List
|
||||
--import Data.List
|
||||
import qualified Control.Foldl as L
|
||||
|
||||
-- | Draw an anticlockwise rectangle based on maximal N E S W values.
|
||||
@@ -111,3 +112,11 @@ grahamEliminate xs = xs
|
||||
|
||||
centroid :: Foldable t => t Point2 -> Point2
|
||||
centroid = L.fold $ (/) <$> L.Fold (+.+) (V2 0 0) id <*> L.genericLength
|
||||
|
||||
shrinkPolyOnEdges :: Float -> [Point2] -> [Point2]
|
||||
shrinkPolyOnEdges x (p:q:ps) = map (shrinkVert x) . slideWindow 3 $ (p:q:ps) ++ [p,q]
|
||||
shrinkPolyOnEdges _ _ = error "too few vertices in polygon"
|
||||
|
||||
shrinkVert :: Float -> [Point2] -> Point2
|
||||
shrinkVert d (x:y:z:[]) = x +.+ (d *.* (normalizeV (x -.- y))) +.+ (d *.* (normalizeV (z -.- y)))
|
||||
shrinkVert _ _ = error "wrong number of vertices"
|
||||
|
||||
Reference in New Issue
Block a user