chiark / gitweb /
4a862cd99a3447fb966ddff6d914aa238b70bf38
[reprap-play.git] / poster-tube-lid.scad.pl
1 #!/usr/bin/perl -w
2 # -*- C -*-
3
4 use strict;
5 use autodie;
6
7 my $settings = <<'END';
8
9 main_dia = 71.2 + 0.50;
10 top_thick = 4;
11
12 main_cnr = 4.0;
13
14 rivet_posn = 6.0;
15 rivet_thick = 1.67;
16 rivet_width = 4.15 + 1.0;
17 rivet_tall = 5.51 + 0.49;
18
19 over_rivet_gap = 1.0;
20 side_rivet_gap = 1.5;
21
22 bayo_interf = 0.75;
23 bayo_behind = 3.5;
24 bayo_interf_width = 2.0;
25 bayo_interf_slope = 0.75;
26
27 seal_thick = 0.1;
28 seal_recess = [ 2.0, 2.0 ]; // recess depth, recess height
29
30 side_taper = 1.0;
31
32 bayo_above_gap = 1.0;
33
34 bayo_entry = bayo_behind/3;
35
36 // calculated
37
38 bayo_entry_x = bayo_entry;
39 bayo_entry_z = bayo_entry;
40 bayo_inramp_x = bayo_entry;
41 bayo_inramp_z = bayo_entry;
42
43 side_height = rivet_posn + bayo_behind + rivet_thick/2;
44 side_thick = rivet_tall + over_rivet_gap;
45
46 top_z = top_thick + seal_thick;
47
48 bayo_entry = bayo_behind / 3.0;
49 bayo_top_z = bayo_behind + rivet_thick + over_rivet_gap;
50 bayo_entry_ramp = bayo_entry + bayo_interf;
51
52 rivet_entry_width = rivet_width + side_rivet_gap;
53
54 $fs=0.5;
55 $fa=5;
56
57 // bayonet definition
58
59 bayo_a = [ bayo_entry_x, 0 ];
60 bayo_p = [ 0, bayo_entry_z ];
61 bayo_n = [ 0, bayo_behind-bayo_inramp_z ];
62 bayo_m = [ bayo_inramp_x, bayo_behind ];
63 bayo_l = bayo_m + bayo_interf * [ 1/bayo_interf_slope,  1 ];
64 bayo_k = bayo_l + [ bayo_interf_width, 0 ];
65 bayo_j = bayo_k + bayo_interf * [ 1/bayo_interf_slope, -1 ];
66 bayo_i = bayo_j + [ rivet_width, 0 ];
67 bayo_h = [ bayo_i[0], bayo_behind + rivet_thick + over_rivet_gap ];
68 bayo_g = [ bayo_m[0] - rivet_width, bayo_h[1] ];
69
70 bayo_e = [-bayo_p[0], bayo_p[1]] - [rivet_entry_width,0];
71 bayo_d = [-bayo_a[0], bayo_a[1]] - [rivet_entry_width,0];
72 bayo_c = bayo_d + [0,-5];
73 bayo_b = bayo_a + [0,-5];
74
75 bayo_f = [ bayo_e[0], bayo_g[1] + (bayo_e[0] - bayo_g[0]) ];
76
77 bayo_polygon = [ bayo_a,
78                  bayo_b,
79                  bayo_c,
80                  bayo_d,
81                  bayo_e,
82                  bayo_f,
83                  bayo_g,
84                  bayo_h,
85                  bayo_i,
86                  bayo_j,
87                  bayo_k,
88                  bayo_l,
89                  bayo_m,
90                  bayo_n,
91                  bayo_p ];
92
93 echo(bayo_polygon);
94
95 END
96
97 my $mainbody = <<'END';
98
99 module MainProfile(){
100   main_cnr_pos = [ side_thick, top_z ] - [1,1]*main_cnr;
101   translate(main_cnr_pos){
102     intersection(){
103       difference(){
104         circle(r = main_cnr);
105         circle(r = main_cnr * 0.5);
106       }
107       square([10,10]);
108     }
109   }
110   polygon([[ -1,                    seal_thick        ],
111            [ -1,                    top_z             ],
112            [ main_cnr_pos[0],       top_z             ],
113            [ side_thick,            main_cnr_pos[1]   ],
114            [ side_thick,            -side_height      ],
115            [ side_taper,            -side_height      ],
116            [ 0,                     -rivet_posn       ],
117            [ 0,                     -(seal_recess[0] + seal_recess[1]) ],
118            [ seal_recess[0],        -(seal_recess[0]) ],
119            [ seal_recess[0],        seal_thick        ],
120            ]);
121 }
122
123 translate([-20,0]) MainProfile();
124
125 polygon(bayo_polygon);
126
127 END
128
129 print $settings, $mainbody or die $!;
130