diff options
-rw-r--r-- | shelves.hs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/shelves.hs b/shelves.hs new file mode 100644 index 0000000..be37931 --- /dev/null +++ b/shelves.hs | |||
@@ -0,0 +1,46 @@ | |||
1 | import Text.Printf | ||
2 | import Linear.V3 | ||
3 | --import Control.Lens | ||
4 | |||
5 | sp xa@(_:xs) = sp xs ++ [sum(xa)] | ||
6 | |||
7 | |||
8 | -- fo2 f xs = | ||
9 | |||
10 | --repeatlast xs = xs ++ | ||
11 | -- sp sh = 0 ++ head sh ++ | ||
12 | |||
13 | shelf_thickness = 0.5 | ||
14 | shelf_width = 4 | ||
15 | shelf_length = 16 | ||
16 | shelfd = [shelf_thickness, shelf_width, shelf_length] | ||
17 | |||
18 | shelf_heights = [2,3,5,5] | ||
19 | sh = shelf_heights | ||
20 | |||
21 | --side_dims = [0.5,last sh,shelf_width] | ||
22 | --side_poss = [[0,0,0], [shelf_length + (side_dims[0] * 2), 0, 0]] | ||
23 | |||
24 | |||
25 | -- working algorithm doing the same as `scanl (+) 0 shelf_heights` | ||
26 | --acc [] = [0] | ||
27 | --acc xs = acc(init xs) ++ [sum xs] | ||
28 | |||
29 | |||
30 | shelf_y_poss = scanl (+) 0 shelf_heights | ||
31 | shelf_poss = [ [0,y,0] | y <- shelf_y_poss ] | ||
32 | shelf_height = sum shelf_heights | ||
33 | |||
34 | scad_place_board pos dim = "transform(" ++ show(pos) ++ ") { cube(" ++ show(dim) ++ ");}" | ||
35 | scad_place_shelf pos = scad_place_board pos shelfd | ||
36 | scad_place_shelves = map (scad_place_shelf) shelf_poss | ||
37 | --scad_place_sides = map (scad_place_board) [ [0, 0, 0], | ||
38 | |||
39 | --scad_place_shelf vpos = scad_place_board show([0, vpos, 0]) show(shelfd) | ||
40 | |||
41 | |||
42 | --gen_openscad = map (scad_place_piece | ||
43 | |||
44 | --accu [x] = x | ||
45 | --accu xs = sum(xs) ++ accu(tail xs) | ||
46 | -- OUTPUT: [0,5,8,10] | ||