summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven <steven.vasilogianis@gmail.com>2019-02-25 03:43:32 -0500
committerSteven <steven.vasilogianis@gmail.com>2019-02-25 03:43:32 -0500
commit3e6c8dede8ac3506dbf9de06ebbb11f4469562ac (patch)
tree0ba990861467594bae5310226840ab533a6906d2
initial cad sandbox
-rw-r--r--shelves.hs46
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 @@
1import Text.Printf
2import Linear.V3
3--import Control.Lens
4
5sp xa@(_:xs) = sp xs ++ [sum(xa)]
6
7
8-- fo2 f xs =
9
10--repeatlast xs = xs ++
11-- sp sh = 0 ++ head sh ++
12
13shelf_thickness = 0.5
14shelf_width = 4
15shelf_length = 16
16shelfd = [shelf_thickness, shelf_width, shelf_length]
17
18shelf_heights = [2,3,5,5]
19sh = 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
30shelf_y_poss = scanl (+) 0 shelf_heights
31shelf_poss = [ [0,y,0] | y <- shelf_y_poss ]
32shelf_height = sum shelf_heights
33
34scad_place_board pos dim = "transform(" ++ show(pos) ++ ") { cube(" ++ show(dim) ++ ");}"
35scad_place_shelf pos = scad_place_board pos shelfd
36scad_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]