4 include <commitid.scad>
24 interlock_fine = 0.66;
26 interlock_fine_slope = 1.0;
27 interlock_fine_lenslop = 1.0;
33 machine_rear_to_front = 84 + 0.25 - 1.4;
35 cutout_l_end_y_front_slop = 0.5;
36 cutout_l_end_y_rear_slop = 0.5;
37 cutout_l_end_x_slop = 0.25;
40 cutout_l_end_y = machine_rear_to_front;
41 cutout_l_end_curve = 1;
42 cutout_l_end_y_total = cutout_l_end_y
43 + cutout_l_end_y_front_slop + cutout_l_end_y_rear_slop;
45 tile02_tr = [-250, 0];
48 cutout_tile01_y = 170 - 147 + cutout_l_end_y_front_slop;
49 cutout_tile11_x = cutout_l_end_x + cutout_l_end_curve;
50 cutout_tile11_y = cutout_l_end_y_total - cutout_tile01_y;
52 // front and rear curves
56 rearcurve_strt_len = 52;
58 rearcurve_z_slop = -0.50;
60 rearcurve_avoid_y = 35;
62 rearcurve_double_inrad = 26.10 + 8.04;
68 frontcurve_side_skew = 3.5 / 72;
69 frontcurve_avoid_y = 70;
70 frontcurve_z_slop = 0.75;
72 frontcurve_strt_len = 50;
73 frontcurve_dualcurve_angle = 30;
79 ply_edge_hole_dist = ply_edge_min + ply_hole_dia/2;
81 echo(str("HOLES IN PLY ctr dist from PLY edge = ", ply_edge_hole_dist));
83 hole_slop = (ply_hole_dia - post_dia)/2;
84 tile_hard_edge_hole_dist = ply_edge_hole_dist + hole_slop;
86 echo(str("HOLES IN PLY ctr dist from TILE HARD edge = ",
87 tile_hard_edge_hole_dist));
89 echo(str("HOLES IN PLY ctr dist from TILE ROUND edge = ",
90 tile_hard_edge_hole_dist + round_edge_rad));
92 thehd = [ tile_hard_edge_hole_dist, tile_hard_edge_hole_dist ];
94 thehd_tl = [ -thehd_tr[0], thehd_tr[1] ];
98 tablet_z_slop = rearcurve_z_slop;
100 interlock_rad = interlock_dia/2;
101 interlock_negative_rad = interlock_rad + 0.125;
103 interlock_sq_adj = 0.2; // arbitrary
105 m4_define(`POST_TCROSSSZ',
106 `2*( tile_hard_edge_hole_dist - test_edge + 1 )')
111 cylinder(r= post_dia/2, h= tile_th + ply_th - post_shorter);
112 translate([0,0, tile_th]) {
113 cylinder(r= screw_big_dia/2, h= screw_big_len);
114 cylinder(r= screw_dia/2, h= ply_th, $fn=20);
118 translate([0,0, tile_th/2]) {
119 cube([post_dia, POST_TCROSSSZ, tile_th], center=true);
120 cube([POST_TCROSSSZ, post_dia, tile_th], center=true);
126 module Posts(posts) {
128 translate(concat(p, [0]))
133 module TileBase(botleft, topright){
134 size = topright - botleft;
135 botleft_post = botleft + thehd_tr;
136 topright_post = topright + thehd_bl;
139 translate(concat(botleft, [0]))
140 cube(concat(size, [tile_th]));
142 cidsz = topright_post-botleft_post
143 + [-post_dia,-post_dia]
145 cidszr = [ min(cidsz[0],50), min(cidsz[1],50) ];
146 echo("CID",cidsz,cidszr);
147 translate( concat(botleft_post, [ -tile_th ])
148 + 0.5 * [ post_dia, post_dia, 0 ]
149 + 0.5 * concat( cidsz - cidszr, [ 0 ]) )
150 Commitid_BestCount_M(cidszr);
153 crossoff = tile_hard_edge_hole_dist + POST_TCROSSSZ/2;
154 cidsz = [ thehd[0], size[1] - 2*crossoff ];
155 cidszr = [ cidsz[0], min(cidsz[1], 50) ];
156 translate( concat(botleft + [0, crossoff] + (cidsz-cidszr)/2, [0]) )
157 Commitid_BestCount(cidszr);
160 translate(concat(botleft + [test_edge,test_edge], [test_tile_th]))
161 cube(concat(size - [test_edge,test_edge]*2, [tile_th]));
162 translate(concat(botleft_post, [-1]))
163 cube(concat(topright_post-botleft_post, [tile_th+2]));
165 shufflesz = max(test_edge, tile_hard_edge_hole_dist)*2;
168 cube(shufflesz, center=true);
176 m4_dnl c is from Rectangle_corners and
177 m4_dnl ix is a corner number
178 m4_dnl expands to two comma-separated corners:
179 m4_dnl that denoted by ix, and the next one anticlockwise
180 m4_define(`R_EDGE',`$1[$2], $1[(($2)+1)%4]')
183 m4_dnl c is from Rectangle_corners and
184 m4_dnl ix is a corner number
185 m4_dnl expands to an array of corners as for RoundCorner
186 m4_define(`R_CNR',`[ $1[$2], $1[(($2)+1)%4], $1[(($2)+3)%4] ]')
188 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars) { body; }
189 m4_define(`INREFFRAME',`
190 length_vec = ($2) - ($1);
191 length = dist2d([0,0], length_vec);
192 length_uvec = length_vec / length;
193 ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
194 m = [ [ length_uvec[0], ortho_uvec[0], 0, ($1)[0], ],
195 [ length_uvec[1], ortho_uvec[1], 0, ($1)[1], ],
202 m4_dnl INREFFRAME(left_cnr, right_cnr, morevars)
203 m4_dnl INREFFRAME_EDGE { body; }
204 m4_define(`INREFFRAME_EDGE',`
205 translate([0,0, -round_edge_rad])
208 module RoundEdge(left_cnr, right_cnr) {
209 INREFFRAME(left_cnr, right_cnr)
213 cylinder(r= round_edge_rad, h= length, $fn=50);
214 translate([-1, 0, -20])
215 cube([length+2, 20, 20]);
220 m4_define(`ROUNDCORNER_VARS',`
224 bigr= round_cnr_rad - round_edge_rad;
225 l_uvec = unitvector2d(left_cnr - this_cnr);
226 r_uvec = unitvector2d(right_cnr - this_cnr);
227 lp1 = left_cnr + clockwise2d(l_uvec) * bigr;
228 lp2 = this_cnr + clockwise2d(l_uvec) * bigr;
229 lp3 = this_cnr - clockwise2d(r_uvec) * bigr;
230 lp4 = right_cnr - clockwise2d(r_uvec) * bigr;
231 ctr = line_intersection_2d(lp1,lp2,lp3,lp4);
232 ctr3 = concat(ctr,[0])
235 module RoundCorner_selector(ci, adj) {
239 INREFFRAME(ctr3,concat(lp1,[4])){
240 translate([0,0,-bigr]) linear_extrude(height=bigr*2) {
241 translate([-bigr*2 + adj, -bigr])
242 square([bigr*2, bigr*3]);
247 INREFFRAME(ctr3,concat(lp4,[0])){
248 translate([0,0,-bigr]) linear_extrude(height=bigr*2) {
249 translate([-bigr*2, -bigr*2])
250 square([bigr*2 + adj, bigr*3]);
257 module RoundCornerCut(ci) {
258 // ci should be [this_cnr, right_cnr, left_cnr]
259 // where right_cnr is to the right (ie, anticlockwise)
262 RoundCorner_selector(ci, -0.1);
264 cylinder(center=true, h=20, r= bigr);
268 module RoundCornerAdd(ci) {
271 RoundCorner_selector(ci, +0.1);
274 rotate_extrude(convexity=10, $fn=50)
277 circle(r= round_edge_rad, $fn=50);
286 module InterlockLobePlan(negative) {
287 r = negative ? interlock_negative_rad : interlock_rad;
288 ymir = negative ? 0 : 1;
292 translate([thehd[0], 0]){
296 translate([-dx, -0.1])
297 square([ dx*2, r/2 + 0.1 ]);
299 translate([ xi*dx, r ])
307 module InterlockEdgePlan(negative, nlobes, length, dosquare=true) {
308 for (lobei = [ 0 : nlobes-1 ]) {
309 lobex = (length - thehd[0]*2) * (lobei ? lobei / (nlobes-1) : 0);
310 translate([lobex, 0, 0]) {
311 InterlockLobePlan(negative);
317 slotshorter = negative ? -0.1 : interlock_fine_lenslop;
318 mirror([0, negative])
319 translate([slotshorter, iadj])
320 square([length - slotshorter*2, interlock_fine + iadj*2]);
324 module InterlockEdge(left_cnr, right_cnr, negative=0, nlobes=2) {
325 plusth = negative * 1.0;
326 protr = interlock_fine + interlock_sq_adj;
329 z1 = -tile_th/2 - protr / interlock_fine_slope;
330 z3 = -tile_th/2 + protr / interlock_fine_slope;
332 negsign = negative ? -1 : +1;
333 yprotr = negsign * protr;
335 INREFFRAME(left_cnr, right_cnr) {
336 for (vsect = [ // zs0 zs1 ys0, ys1
337 [ -tile_th-plusth, plusth, 0, 0],
338 [ z1, z2, 0, yprotr],
339 [ z2, z3, yprotr, 0],
349 [ 0,1, -sl, -ys0 + negsign*interlock_sq_adj ],
353 linear_extrude(height=zsd, convexity=10)
354 InterlockEdgePlan(negative, nlobes, length, !!ysd);
359 function TestPiece_holes2corners(holes) =
360 [ holes[0] + thehd_bl,
363 holes[0] + thehd_tl ];
365 module TestPiece1(){ ////toplevel
369 corners = TestPiece_holes2corners(holes);
370 rcs = R_CNR(corners,0);
373 TileBase(corners[0], corners[2]);
375 RoundEdge(corners[0], corners[1]);
376 RoundEdge(corners[3], corners[0]);
378 InterlockEdge(corners[1], corners[2], 1, nlobes=1);
384 module TestPiece2(){ ////toplevel
388 corners = TestPiece_holes2corners(holes);
389 TileBase(corners[0], corners[2]);
391 RoundEdge(corners[0], corners[1]);
392 InterlockEdge(corners[3], corners[0], 0, nlobes=1);
395 module TestDemo(){ ////toplevel
396 translate([ -thehd[0], 0 ])
399 translate([ +thehd[0] + demo_slop, 0 ])
403 module Machine_Arm(){
404 ysz = cutout_l_end_y_total;
405 // assume the round end is arc of a circle
406 chordlen = dist2d([0,0], [ cutout_l_end_y, cutout_l_end_curve ]);
407 endrad = cutout_l_end_y / cutout_l_end_curve * chordlen;
409 translate([0,0,-30]) linear_extrude(height=60) {
410 translate(tile01_tr + [0, (-cutout_tile01_y + cutout_tile11_y)/2]) {
412 translate([-50, -ysz/2])
414 translate([ endrad - cutout_tile11_x - cutout_l_end_x_slop, 0 ])
415 circle(r=endrad, $fa=0.01,$fd=5);
421 module Machine_NewRearProfile(){
422 // figures copied out of xfig edit boxes
423 // best not to edit the posbox size if poss - just move it
424 posbox = 10 * ([7.2333,-14.1267] - [-16.2289,40.0289]); // box, Green
425 sideline = -10 * ([-6.2400,13.5600] - [-2.4467,28.2556]); // line, Blue
426 scaleline = 10 * dist2d([-1.1911,-20.4800], [-11.2600,4.0578]); // Green2
427 scaleline_mm = 12+5+10+5+3;
428 sh = -[abs(posbox[0]), abs(posbox[1])];
429 rot = atan2(-sideline[0], sideline[1]);
430 sc = scaleline_mm / scaleline;
431 //echo("SH",sh,rot,sc);
432 scale(sc) rotate(rot) translate(sh){
433 import("sewing-table-rear-profile.dxf", convexity=10); // spline, Pink3
437 module Machine_NewFrontProfile(){
438 // figures copied out of xfig edit boxes
439 // best not to edit the posbox size if poss - just move it
440 posbox = 10 * ([11.8022,8.0600] - [4.2044,19.1867]); // box, Green
441 refline = 10 * ([7.6778,16.7222] - [27.8689,17.6578]); // line, Blue
442 refline_mm = (11-1)*10;
443 sh = -[abs(posbox[0]), abs(posbox[1])];
444 rot = atan2(-refline[0], refline[1]);
445 sc = refline_mm / vectorlen2d(refline);
446 //echo("SH",sh,rot,sc);
447 mirror([1,0]) scale(sc) rotate(rot+90) translate(sh){
448 import("sewing-table-front-profile.dxf", convexity=10); // spline, Pink3
452 module Machine_NewRearCurve(){
453 slant = atan2(4,210-10);
455 translate([0,0, rearcurve_double_inrad]) rotate([slant,0,0]){
456 translate([ rearcurve_double_inrad,
458 -rearcurve_double_inrad + 10 ]){
459 rotate([180,0,0]) rotate([0,0,90]) linear_extrude(height=30){
461 Machine_NewRearProfile();
462 translate([0,-100]) Machine_NewRearProfile();
466 rotate([0,90,0]) rotate([90,0,0]) {
468 rotate_extrude(convexity=10, $fn=64)
470 translate([ 0, -rearcurve_double_inrad ])
471 Machine_NewRearProfile();
472 translate([0,0,-500])
473 cube([500,500,1000]);
476 translate([1,0,-rearcurve_double_inrad])
477 rotate([0,-90,0]) rotate([0,0,-90])
478 linear_extrude(height= rearcurve_strt_len + 1)
479 Machine_NewRearProfile();
483 module Machine_Curves(){ ////toplevel
484 translate([ tile01_tr[0] - cutout_l_end_x + rearedge_len,
488 translate([ -reartablet_x,
490 -reartablet_z + tablet_z_slop])
492 cube([ reartablet_x+1,
496 translate([ tile01_tr[0] - cutout_l_end_x + rearedge_len,
498 frontcurve_z_slop ]){
499 translate([0, -machine_rear_to_front, 0])
500 multmatrix([[1, -frontcurve_side_skew, 0, 0],
504 mirror([1,0,0]) rotate([0,-90,0])rotate([0,0,-90])
505 linear_extrude(height= 200)
506 Machine_NewFrontProfile();
508 translate([ rearcurve_strt_len,
511 Machine_NewRearCurve();
516 module TestStrapSlots(){
524 translate(concat(pos,[0]))
525 for (mx = [0,1]) mirror([mx,0,0]) {
526 translate([ pegwidth/2, -strap[1]/2, -20 ])
527 #cube(concat(strap,[40]));
532 module Machine(){ ////toplevel
539 module MachineEnvelope(){
541 p_arm_bl = [-cutout_tile11_x, -cutout_tile01_y];
542 y_arm_t = cutout_tile11_y;
543 p_crv_fl = p_arm_bl + [rearedge_len, -frontcurve_avoid_y];
544 y_crv_b = y_arm_t + rearcurve_avoid_y;
546 translate([0,0,-50]) linear_extrude(height= 100){
547 translate(p_arm_bl) square([400, y_arm_t] - p_arm_bl);
548 translate(p_crv_fl) square([400, y_crv_b] - p_crv_fl);
552 function Rectangle_corners(c0, sz) =
553 // returns the corners of a rectangle from c0 to c0+sz
554 // if sz is positive, the corners are anticlockwise starting with c0
557 c0 + [ sz[0], sz[1] ],
560 function Rectangle_corners2posts(c) =
566 module Rectangle_TileBase(c) { TileBase(c[0], c[2]); }
568 function Posts_interpolate_one(c0,c1) = [c0, (c0+c1)/2, c1];
570 module Tile02(){ ////toplevel
572 c0 = tile02_tr + -sz;
573 c = Rectangle_corners(c0, sz);
574 posts = Rectangle_corners2posts(c);
578 Rectangle_TileBase(c);
580 RoundEdge(R_EDGE(c,0));
581 RoundEdge(R_EDGE(c,3));
582 InterlockEdge(R_EDGE(c,2), 0);
584 InterlockEdge(R_EDGE(c,1), 1);
590 module Tile12(){ ////toplevel
592 c0 = tile02_tr + [-sz[0], 0];
593 c = Rectangle_corners(c0, sz);
594 posts = Rectangle_corners2posts(c);
598 Rectangle_TileBase(c);
600 RoundEdge(R_EDGE(c,2));
601 RoundEdge(R_EDGE(c,3));
603 InterlockEdge(R_EDGE(c,0), 1);
604 InterlockEdge(R_EDGE(c,1), 1);
610 tile_01_11_cnr = tile01_tr + [-cutout_tile11_x, 0];
611 tile_11_10_cnr = tile01_tr + [0, cutout_tile11_y];
612 tile_01_00_cnr = tile01_tr - [0, cutout_tile01_y];
614 module Tile11(){ ////toplevel
616 c0 = tile01_tr + [-sz[0],0];
617 c = Rectangle_corners(c0, sz);
618 cnr_posts = Rectangle_corners2posts(c);
620 Posts_interpolate_one(cnr_posts[0],
621 cnr_posts[1] - [cutout_tile11_x, 0]),
622 [ cnr_posts[1] + [0, cutout_tile11_y],
628 Rectangle_TileBase(c);
630 RoundEdge(R_EDGE(c,2));
631 InterlockEdge(R_EDGE(c,3));
633 InterlockEdge(c[0], tile_01_11_cnr, 1);
634 InterlockEdge(tile_11_10_cnr, c[2], 1);
639 module Tile01(){ ////toplevel
641 c0 = tile01_tr + -sz;
642 c = Rectangle_corners(c0, sz);
643 cnr_posts = Rectangle_corners2posts(c);
645 Posts_interpolate_one(R_EDGE(cnr_posts,0)),
646 [ cnr_posts[2] + [0, -cutout_tile01_y] ],
647 Posts_interpolate_one(cnr_posts[2] - [cutout_tile11_x, 0],
652 Rectangle_TileBase(c);
654 RoundEdge(R_EDGE(c,0));
655 InterlockEdge(tile_01_11_cnr, c[3]);
656 InterlockEdge(R_EDGE(c,3));
658 InterlockEdge(c[1], tile_01_00_cnr, 1);
663 module Tile10(){ ////toplevel
665 c0 = tile01_tr + [0,0];
666 c = Rectangle_corners(c0, sz);
667 cnr_posts = Rectangle_corners2posts(c);
668 cty = cutout_tile11_y;
669 rcy = cty + rearcurve_avoid_y;
670 posts = [ cnr_posts[0] + [ 0, cty ],
671 cnr_posts[1] + [ -sz[0] + rearedge_len - cutout_l_end_x, cty ],
672 cnr_posts[1] + [ 0, rcy ],
678 Rectangle_TileBase(c);
680 RoundEdge(R_EDGE(c,1));
681 RoundEdge(R_EDGE(c,2));
682 InterlockEdge(c[3], tile_11_10_cnr);
690 module Tile00(){ ////toplevel
692 c0 = tile01_tr + [0,-sz[1]];
693 c = Rectangle_corners(c0, sz);
695 // the edge c[1]..c[2] needs a diagonal chunk, from c1bis to c2bis
696 c2bis = [ -cutout_l_end_x + rearedge_len + frontcurve_strt_len, c[2][1] ];
699 (c[2][0] - c2bis[0]) * tan(90 - frontcurve_dualcurve_angle) ];
701 cnr_posts = Rectangle_corners2posts(c);
702 cty = cutout_tile01_y;
703 rcy = cty + frontcurve_avoid_y;
704 posts = [ cnr_posts[0],
706 cnr_posts[2] + [ 0, -rcy ],
707 cnr_posts[2] + [ -sz[0] + rearedge_len - cutout_l_end_x, -cty ],
708 cnr_posts[3] + [ 0, -cty ]
711 rc2 = [c1bis,c2bis,c[1]];
716 Rectangle_TileBase(c);
718 RoundEdge(R_EDGE(c,0));
719 RoundEdge(c[1], c1bis);
720 InterlockEdge(tile_01_00_cnr, c[0]);
723 translate([0,0,-20]) linear_extrude(height=40) {
724 polygon([ c1bis, c1bis + [50,0], c2bis + [50,0], c2bis ]);
727 RoundEdge(c1bis, c2bis);
736 module FitTest_general(c0,sz, dobrace=false, bracexx=0){
737 c = Rectangle_corners(c0, sz);
739 bsz = sz + [bracexx,0,0];
742 Rectangle_TileBase(c);
744 translate(concat(c0, [-brace[2] + 0.1])){
746 cube(concat(bsz, [brace[2]]) - [5,0,0]);
747 translate(brace + [0,0, -25])
748 cube(concat(bsz, [50]) - brace*2 + [10,0,0]);
752 RoundEdge(R_EDGE(c,1));
758 module FitTest_PairLink(cut=false){ ////toplevel
759 cy0=-55; cy1=85; cx=132;
762 footrad_min = 1; footrad_max = 4; footrad_depth = 5;
768 straphole_x_max = legrad/sqrt(2) + footrad_max;
769 dz = cut ? adj_neg_slop : 0;
771 translate([cx - bar[0]/2, cy0, dz + bar_z_slop])
772 cube([bar[0], cy1-cy0, bar[1] - bar_z_slop]);
774 for (endy=[cy0,cy1]) {
776 translate([cx,endy,dz]){
778 for (rot=[45:90:315]) rotate(rot) {
779 translate([legrad,0,0]){
781 cylinder(r= footrad_max, h=1);
782 translate([0,0,-footrad_depth])
783 cylinder(r= footrad_min, h=1);
786 cylinder(r= footrad_min +
787 adj_neg_slop * (footrad_max-footrad_min)/footrad_depth,
792 for (rot=[45,135]) rotate(rot) {
795 translate([s*legrad,0,0])
796 cylinder(r= footrad_max, h=bar[1]);
802 for (rot=[0,180]) rotate(rot) {
803 translate([ straphole_x_max - strap[0]/2, 0,0 ])
804 cube(concat(strap,[20]), center=true);
811 module FitTest_RearCurve(){ ////toplevel
813 FitTest_general([100,0], [180,100]);
814 FitTest_PairLink(true);
819 module FitTest_FrontCurve(){ ////toplevel
825 translate([0,0,-8]) linear_extrude(height=18) {
826 translate(p0) square(sz);
829 FitTest_PairLink(true);
833 module FitTest_Entire(){ ////toplevel
836 szfront = [250,szrear[1]];
838 FitTest_general(p0, szrear, dobrace=true, bracexx=0);
839 FitTest_PairLink(true);
840 translate(concat(p0,[0]) + [szfront[0],-10,-40])
841 cube([100, -p0[1], 80]);
845 translate(concat(p0,[-20])) cube(concat(szrear,[40]));
847 FitTest_FrontCurve();
850 module FitTest_EntireDemo(){ ////toplevel
855 module FitTest_PairDemo(){ ////toplevel
859 %FitTest_FrontCurve();
860 %FitTest_RearCurve();
866 FitTest_FrontCurve();
869 #FitTest_PairLink(true);
875 module RoundCornerDemo_plat(cnr){
876 mirror([0,0,1]) linear_extrude(height=1) polygon(cnr);
879 module RoundCornerDemo(){ ////toplevel
880 cnr = [ [-2,-3], [13,-3], [-12,9] ];
881 translate([0,25,0]) RoundCornerDemo_plat(cnr);
882 translate([25,0,0]) RoundCornerAdd(cnr);
883 translate([-25,0,0]) RoundCornerCut(cnr);
884 translate([0,-25,0]) RoundCorner_selector(cnr, 0);
886 RoundCornerDemo_plat(cnr);
892 module Demo(){ ////toplevel
893 translate(demo_slop*[-2,1]) color("blue") Tile12();
894 translate(demo_slop*[-2,0]) color("red") Tile02();
895 translate(demo_slop*[-2,1]) color("orange") Tile11();
896 translate(demo_slop*[-2,0]) color("purple") Tile01();
897 translate(demo_slop*[-3,1]) color("blue") Tile10();
898 translate(demo_slop*[-3,0]) color("red") Tile00();
906 //Machine_NewRearProfile();
907 //Machine_NewRearCurve();
908 //Machine_NewFrontProfile();