summaryrefslogtreecommitdiff
path: root/shelves.hs
blob: e42fe7db74b12ae7c863ece0e45c66117b47dcd8 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import Linear.V3
import Control.Lens
import Data.List
import GenSCAD (genscad)

shelf_thickness :: Double
shelf_thickness = 0.5
shelf_width :: Double
shelf_width = 8
shelf_length :: Double
shelf_length = 36 * 2
shelf_dim :: V3 Double
shelf_dim = V3 shelf_length shelf_width shelf_thickness

shelf_heights :: [Double]
shelf_heights = [12, 10, 8, 8, 8, 8, 8]

-- working algorithm doing the same as `scanl (+) 0 shelf_heights`
--acc [] = [0]
--acc xs = acc(init xs) ++ [sum xs]

shelf_height :: Double
shelf_height = (sum shelf_heights) + (shelf_dim ^. _z * (fromIntegral (length shelf_heights) + 1))

side_dim :: V3 Double
side_dim = V3 0.5 shelf_width shelf_height

--shelf_y_poss = scanl (+) 0 shelf_heights
shelf_y_poss :: [Double]
shelf_y_poss = scanl (+) 0 [h+shelf_thickness| h <- shelf_heights]
shelves_pos :: [V3 Double]
shelves_pos = [V3 (side_dim ^. _x) 0 y | y <- shelf_y_poss]
shelves :: [(V3 Double, V3 Double)]
shelves = [(p, shelf_dim) | p <- shelves_pos]

--sides = [(V3 0 0 0, side_dim), (V3 (side_dim ^. _x + shelf_length) 0 0, side_dim)]
sides_pos :: [V3 Double]
sides_pos = [V3 0 0 0, V3 (side_dim ^. _x + shelf_length) 0 0]
sides :: [(V3 Double, V3 Double)]
sides = [(p, side_dim) | p <- sides_pos]

--V3_to_string v = drop 3 (show v)

_V32l :: R3 t => t a -> [a]
_V32l v3 = [v3 ^. _x, v3 ^. _y, v3 ^. _z]
_V32s :: (Show a, R3 t) => t a -> [Char]
_V32s v3 = intercalate ", " (map show (_V32l v3))
--scad_place (p,d)  = "translate([ " ++ _V32s(p) ++ " ]) { cube([ " ++ _V32s(d) ++ " ]);}"
--genscad objs = concat $ map (++ "\n") $ map scad_place objs

scadshelf :: String
scadshelf = genscad $ shelves ++ sides

--gen_shelf :: [Fractional] -> Fractional -> Fractional -> [Char]
--gen_shelf shelf_heights depth length = 



main :: IO ()
main = do putStrLn scadshelf



--main = map (putStrLn) ["one", "two"]

--genshelf = genscad $ shelves ++ sides

--main = map print $ gen_scad $ shelves ++ sides

--scad_place_sides = map (scad_place_board) [[[V3 0 0 0], side_dim], [[V3 side_dim ^. _x, 0, 0], side_dim]]

--scad_place_shelf vpos = scad_place_board show([0, vpos, 0]) show(shelfd)


--genscad shelves ++ sides

--gen_openscad = map (scad_place_piece

--accu [x] = x
--accu xs = sum(xs) ++ accu(tail xs)
-- OUTPUT: [0,5,8,10]