From 3e6c8dede8ac3506dbf9de06ebbb11f4469562ac Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 25 Feb 2019 03:43:32 -0500 Subject: initial cad sandbox --- shelves.hs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 shelves.hs diff --git a/shelves.hs b/shelves.hs new file mode 100644 index 0000000..be37931 --- /dev/null +++ b/shelves.hs @@ -0,0 +1,46 @@ +import Text.Printf +import Linear.V3 +--import Control.Lens + +sp xa@(_:xs) = sp xs ++ [sum(xa)] + + +-- fo2 f xs = + +--repeatlast xs = xs ++ +-- sp sh = 0 ++ head sh ++ + +shelf_thickness = 0.5 +shelf_width = 4 +shelf_length = 16 +shelfd = [shelf_thickness, shelf_width, shelf_length] + +shelf_heights = [2,3,5,5] +sh = shelf_heights + +--side_dims = [0.5,last sh,shelf_width] +--side_poss = [[0,0,0], [shelf_length + (side_dims[0] * 2), 0, 0]] + + +-- working algorithm doing the same as `scanl (+) 0 shelf_heights` +--acc [] = [0] +--acc xs = acc(init xs) ++ [sum xs] + + +shelf_y_poss = scanl (+) 0 shelf_heights +shelf_poss = [ [0,y,0] | y <- shelf_y_poss ] +shelf_height = sum shelf_heights + +scad_place_board pos dim = "transform(" ++ show(pos) ++ ") { cube(" ++ show(dim) ++ ");}" +scad_place_shelf pos = scad_place_board pos shelfd +scad_place_shelves = map (scad_place_shelf) shelf_poss +--scad_place_sides = map (scad_place_board) [ [0, 0, 0], + +--scad_place_shelf vpos = scad_place_board show([0, vpos, 0]) show(shelfd) + + +--gen_openscad = map (scad_place_piece + +--accu [x] = x +--accu xs = sum(xs) ++ accu(tail xs) +-- OUTPUT: [0,5,8,10] -- cgit v1.2.3