Broken commit, just to restore deleted function

This commit is contained in:
2021-09-21 01:28:11 +01:00
parent 7f1a365cac
commit 464b0b16db
6 changed files with 44 additions and 82 deletions
+10 -41
View File
@@ -3,10 +3,7 @@ module Shape
( module Shape.Data
, translateSH
, emptySH
, polyCirc
, upperPrismPoly
, prismPoly
, flatCirc
, translateSHz
, translateSHf
, rotateSH
@@ -26,13 +23,9 @@ emptySH :: Shape
{-# INLINE emptySH #-}
emptySH = mempty
flatCirc :: Float -> Shape
{-# INLINE flatCirc #-}
flatCirc = flatPoly . polyCirc 3
polyCirc :: Int -> Float -> [Point2]
{-# INLINE polyCirc #-}
polyCirc n x = map (\a -> rotateV a (V2 x 0)) $ take (n*2) [0,pi/(fromIntegral n)..]
{-# INLINE polycirc #-}
polyCirc n r = map (\i -> rotateV ) [0..n]
upperPrismPoly
:: Float -- ^ height, expected to be strictly positive
@@ -40,42 +33,18 @@ upperPrismPoly
-> Shape
{-# INLINE upperPrismPoly #-}
upperPrismPoly h ps =
( [ShapeObj ListV (topFace <> sideFaces)]
( [ShapeObj (TopPrism n) (f upps downps)]
, topEdges <> bottomEdges <> sideEdges
)
where
topFace = shVfromList $ polyToTris $ map f' ps
n = length ps
upps = map f' ps
downps = map f'' ps
f (a:as) (b:bs) = a:b:f as bs
f [] _ = []
f _ [] = []
f' (V2 x y) = pairToSV (V3 x y h, black)
sideFaces = shVfromList $ map addCol $ concat
$ zipWith (\a b -> polyToTris (extendSide a b)) ps (tail ps ++ [head ps])
addCol x = pairToSV ( x, black)
extendSide (V2 x y) (V2 x' y') = [V3 x y 0, V3 x' y' 0, V3 x' y' h, V3 x y h]
topEdges = shEfromList $ concat $ zipWith makeTopEdge ps (tail ps ++ [head ps])
makeTopEdge (V2 x y) (V2 x' y') = [V3 x y h,V3 x' y' h,V3 x y 0,V3 xcen ycen h]
V2 xcen ycen = centroid ps
bottomEdges = shEfromList $ concat $ zipWith makeBottomEdge ps (tail ps ++ [head ps])
makeBottomEdge (V2 x' y') (V2 x y) = [V3 x y 0,V3 x' y' 0,V3 x y h,V3 xcen ycen 0]
sideEdges = shEfromList $ concat $ zipWith3 makeSideEdge ps (tail ps ++ [head ps]) (drop 2 ps ++ take 2 ps)
makeSideEdge (V2 xl yl) (V2 x y) (V2 xr yr) = [V3 x y 0, V3 x y h, V3 xr yr 0, V3 xl yl h]
prismPoly
:: Float -- ^ height, expected to be strictly positive
-> [Point2]
-> Shape
{-# INLINE prismPoly #-}
prismPoly h ps =
( [ShapeObj ListV (topFace <> bottomFace <> sideFaces)]
, topEdges <> bottomEdges <> sideEdges
)
where
topFace = shVfromList $ polyToTris $ map f' ps
f' (V2 x y) = pairToSV ( V3 x y h, black )
f (V2 x y) = pairToSV ( V3 x y 0, black )
bottomFace = shVfromList $ polyToTris $ map f $ reverse ps
sideFaces = shVfromList $ map addCol $ concat
$ zipWith (\a b -> polyToTris (extendSide a b)) ps (tail ps ++ [head ps])
addCol x = pairToSV ( x, black)
extendSide (V2 x y) (V2 x' y') = [V3 x y 0, V3 x' y' 0, V3 x' y' h, V3 x y h]
f'' (V2 x y) = pairToSV (V3 x y 0, black)
topEdges = shEfromList $ concat $ zipWith makeTopEdge ps (tail ps ++ [head ps])
makeTopEdge (V2 x y) (V2 x' y') = [V3 x y h,V3 x' y' h,V3 x y 0,V3 xcen ycen h]
V2 xcen ycen = centroid ps