summaryrefslogtreecommitdiff
path: root/shelves-pure.hs
blob: 85873f723b8f415bbb8d46294360553ece646c30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Linear.V3
import Control.Lens
import Data.List

-- Karens Specifies:

shelf_heights = [12, 10, 10, 10, 6, 6]
shelf_length = 16
shelf_depth = 6

shelf_thickness = 0.5
side_thickness = 0.5

-- Behind Karen's Back

shelf_height = sum shelf_heights

sided = V3 side_thickness shelf_height shelf_depth
shelfd = V3 shelf_length shelf_thickness shelf_depth


sideps = [(V3 0 0 0), (V3 (sided ^. _x + shelfd ^. _x) 0 0)]

shelf_ys = scanl (+) 0 shelf_heights
shelfps = [(V3 x 0 0) | x <- shelf_ys]


place_pieces poss piece_dim = [[(p, piece_dim)] |p <- poss]

shelves = place_pieces shelfps shelfd
sides = place_pieces sideps sided

V32l v3 = [v3 ^. _x, v3 ^. _y, v3 ^. _z]
V32s v3 = intercalate ", " (map show (v32l v3))
scadplace obj = genscadstr (fst (head obj)) (snd (head obj))
genscadstr p o = "translate([" ++ v32s p ++ "]) { cube([" ++ v32s o ++ "]); }"
genscad ps = intercalate "" $ map scadplace ps



--genscad ps = map  printf "POS: %s DIM: %s\n" p d) ps)
--genscad ps = ["P: " ++ (fst p) ++ " | O: " ++ (snd p) |p<-ps]
--genscad ps = [fst(p) |p<-ps]
--genscad ps = ["P: " ++ p ++ "D: " ++ d|(p,d) <- ps]
--genscad ps = map ()

main = print 1
--main = print $ genscad (shelves ++ sides)