summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven <steven.vasilogianis@gmail.com>2019-03-20 01:01:36 -0400
committerSteven <steven.vasilogianis@gmail.com>2019-03-20 01:01:36 -0400
commitc8ecdd4b892e819555bcd6a7cef76197dd864f2c (patch)
tree3b9e3b34967dbf508596d051ad2adc79d5335546
parent77ec844f6ce0d1b7129c04e5dd31d2383680db4b (diff)
filled in stubs
removed old code
-rw-r--r--shelves.hs103
1 files changed, 21 insertions, 82 deletions
diff --git a/shelves.hs b/shelves.hs
index 0484ff5..73551f2 100644
--- a/shelves.hs
+++ b/shelves.hs
@@ -1,88 +1,27 @@
1import Control.Lens
2import GenSCAD (genscad)
3import Graphics.OpenSCAD 1import Graphics.OpenSCAD
4import Linear.V3
5 2
6data Shelf 3data Shelf = Shelf {
4 width :: Double,
5 depth :: Double,
6 boardThickness :: Double,
7 shelfHeights :: [Double]
8} deriving (Show)
7 9
8myShelf :: Shelf 10myShelf :: Shelf
9myShelf = undefined 11myShelf = Shelf { width = 36, depth = 8, boardThickness = 1,
10 12 shelfHeights = [12, 12, 10, 10, 6, 6, 6] }
11modelShelf :: Shelf -> Model3d 13
12modelShelf = undefined 14modelShelf :: Shelf -> [Model3d]
15modelShelf s =
16 let sidesPos = [(0,0,0), (boardThickness s + width s, 0, 0)]
17 shelvesPos = let ys = scanl (+) 0 [h + boardThickness s|h <- shelfHeights s]
18 in [ (boardThickness s, 0, y) | y <- ys ]
19 place board places = map (\p -> translate p board) places
20 in place sideBoard sidesPos ++ place shelfBoard shelvesPos
21 where shelfHeight = sum (shelfHeights s) + (boardThickness s) *
22 (fromIntegral (length $ shelfHeights s) + 1)
23 sideBoard = box (boardThickness s) (depth s) shelfHeight
24 shelfBoard = box (width s) (depth s) (boardThickness s)
13 25
14main :: IO () 26main :: IO ()
15main = draw $ modelShelf myShelf 27main = drawL $ modelShelf myShelf
16
17shelf_thickness :: Double
18shelf_thickness = 0.5
19shelf_width :: Double
20shelf_width = 8
21shelf_length :: Double
22shelf_length = 36 * 2
23shelf_dim :: V3 Double
24shelf_dim = V3 shelf_length shelf_width shelf_thickness
25
26shelf_heights :: [Double]
27shelf_heights = [12, 10, 8, 8, 8, 8, 8]
28
29-- working algorithm doing the same as `scanl (+) 0 shelf_heights`
30--acc [] = [0]
31--acc xs = acc(init xs) ++ [sum xs]
32
33shelf_height :: Double
34shelf_height = (sum shelf_heights) + (shelf_dim ^. _z * (fromIntegral (length shelf_heights) + 1))
35
36side_dim :: V3 Double
37side_dim = V3 0.5 shelf_width shelf_height
38
39--shelf_y_poss = scanl (+) 0 shelf_heights
40shelf_y_poss :: [Double]
41shelf_y_poss = scanl (+) 0 [h+shelf_thickness| h <- shelf_heights]
42shelves_pos :: [V3 Double]
43shelves_pos = [V3 (side_dim ^. _x) 0 y | y <- shelf_y_poss]
44shelves :: [(V3 Double, V3 Double)]
45shelves = [(p, shelf_dim) | p <- shelves_pos]
46
47--sides = [(V3 0 0 0, side_dim), (V3 (side_dim ^. _x + shelf_length) 0 0, side_dim)]
48sides_pos :: [V3 Double]
49sides_pos = [V3 0 0 0, V3 (side_dim ^. _x + shelf_length) 0 0]
50sides :: [(V3 Double, V3 Double)]
51sides = [(p, side_dim) | p <- sides_pos]
52
53--V3_to_string v = drop 3 (show v)
54
55--scad_place (p,d) = "translate([ " ++ _V32s(p) ++ " ]) { cube([ " ++ _V32s(d) ++ " ]);}"
56--genscad objs = concat $ map (++ "\n") $ map scad_place objs
57
58scadshelf :: String
59scadshelf = genscad $ shelves ++ sides
60
61--gen_shelf :: [Fractional] -> Fractional -> Fractional -> [Char]
62--gen_shelf shelf_heights depth length =
63
64
65
66-- main :: IO ()
67-- main = do putStrLn scadshelf
68
69
70
71--main = map (putStrLn) ["one", "two"]
72
73--genshelf = genscad $ shelves ++ sides
74
75--main = map print $ gen_scad $ shelves ++ sides
76
77--scad_place_sides = map (scad_place_board) [[[V3 0 0 0], side_dim], [[V3 side_dim ^. _x, 0, 0], side_dim]]
78
79--scad_place_shelf vpos = scad_place_board show([0, vpos, 0]) show(shelfd)
80
81
82--genscad shelves ++ sides
83
84--gen_openscad = map (scad_place_piece
85
86--accu [x] = x
87--accu xs = sum(xs) ++ accu(tail xs)
88-- OUTPUT: [0,5,8,10]