chiark / gitweb /
1fa1df07fe73d605e1f01095bd45c74ecaf73186
[reprap-play.git] / sewing-table.scad.m4
1 // -*- C -*-
2
3 include <funcs.scad>
4
5 ply_th = 18;
6 ply_hole_dia = 15;
7 ply_edge_min = 10;
8
9 tile_th = 3;
10 post_dia = 8;
11
12 post_shorter = 1;
13
14 screw_dia = 2.2;
15 screw_big_dia = 3.6;
16 screw_big_len = 4.0;
17
18 round_edge_rad = 2.0;
19
20 // calculated
21
22 ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2;
23
24 echo(str("HOLES IN PLY ctr dist from edge = ", ply_edge_hole_dist));
25
26 hole_slop = (ply_hole_dia - post_dia)/2;
27 tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop;
28 thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ];
29
30 module Post(){
31   mirror([0,0,1]) {
32     difference(){
33       cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter);
34       translate([0,0, tile_th]) {
35         cylinder(r= screw_big_dia/2, h= screw_big_len);
36         cylinder(r= screw_dia/2, h= ply_th, $fn=20);
37       }
38     }
39   }
40 }
41
42 module Posts(posts) {
43   for (p= posts) {
44     translate([p[0], p[1], 0])
45       Post();
46   }
47 }
48
49 module TileBase(botleft_post, topright_post){
50   botleft = botleft_post - thehd;
51   size = topright_post - botleft_post + thehd * 2;
52   mirror([0,0,1])
53     translate([botleft[0], botleft[1], 0])
54     cube([size[0], size[1], tile_th]);
55 }
56
57 m4_dnl  INREFFRAME(left_post, right_post, morevars) { body; }
58 m4_define(`INREFFRAME',`
59   length_vec = ($2) - ($1);
60   length = dist2d([0,0], length_vec);
61   length_uvec = length_vec / length;
62   ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
63   m = [ [ length_uvec[0],  ortho_uvec[0], 0, ($1)[0], ],
64         [ length_uvec[1],  ortho_uvec[1], 0, ($1)[1], ],
65         [ 0,              0,              1,            0, ],
66         [ 0,              0,              0,            1, ] ];
67   $3
68   multmatrix(m)
69 ')
70
71 m4_dnl  INREFFRAME(left_post, right_post, morevars)
72 m4_dnl    INREFFRAME_EDGE { body; }
73 m4_define(`INREFFRAME_EDGE',`
74   translate([-thehd[1], -thehd[0], -round_edge_rad])
75 ')
76
77 module RoundEdge(left_post, right_post) {
78   INREFFRAME(left_post, right_post,
79               `tlength = length + thehd[1] * 2;') m4_dnl '
80     INREFFRAME_EDGE {
81     difference(){
82       rotate([0,90,0])
83         cylinder(r= round_edge_rad, h= tlength, $fn=50);
84       translate([-1, 0, -20])
85         cube([tlength+2, 20, 20]);
86     }
87   }
88 }
89
90 module RoundLeftCorner(this_post, right_post) {
91   INREFFRAME(this_post, right_post) INREFFRAME_EDGE {
92     difference(){
93       sphere(r= round_edge_rad, $fn=60);
94       translate([0,0, -20])
95         cube([20,20,20]);
96     }
97   }
98 }
99
100 module InterlockNegative(this_post, right_post) {
101 }
102
103 module TestPiece1(){
104   holes = [ [-100, 0],
105             [   0, 0]
106             ];
107   difference(){
108     TileBase(holes[0], holes[1]);
109     InterlockNegative(holes[1], holes[1] + [0,1]);
110
111   }
112   Posts(holes);
113   RoundEdge(holes[0], holes[1]);
114   RoundEdge(holes[0] + [ 0, 0.1 ], holes[0]);
115   RoundLeftCorner(holes[0], holes[1]);
116 }
117
118 TestPiece1();