chiark / gitweb /
sewing-table: introduce INREFFRAME
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 30 Dec 2016 16:18:18 +0000 (16:18 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 30 Dec 2016 16:18:18 +0000 (16:18 +0000)
.gitignore
Makefile
sewing-table.scad.m4 [moved from sewing-table.scad with 65% similarity]

index f53fd1865918bbebf7eef1c2bf4aeda9c8c8bdcb..71fbe9ecde796f497747f4f6d197ece30020b273 100644 (file)
@@ -22,3 +22,4 @@ commitid-best-test.scad
 filamentspool-number-n*.dxf
 filamentspool-number-n*.eps
 sealing-box.scad
+sewing-table.scad
index c402fe362e64bfd27279e66422b89462b1bf7936..1aac776df4e339845d6af247bad4c4f071d88d61 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ USING_AUTOS ?= $(FILAMENTSPOOL_AUTOS) xeno-drivebay-bracket dungeonquest-cone an
 
 AUTO_TOPLEVELS := $(foreach m,$(USING_AUTOS),$(shell $(PLAY)/toplevel-find $m))
 
-AUTO_INCS = funcs.scad utils.scad sealing-box.scad
+AUTO_INCS = funcs.scad utils.scad sealing-box.scad sewing-table.scad
 
 default:       autoincs scads
 
similarity index 65%
rename from sewing-table.scad
rename to sewing-table.scad.m4
index 0da937c380b59403449eabe83e9b14f8ab30c0c9..3d2ce81a9a469d964de2d39d01cb8cc3c8edd43d 100644 (file)
@@ -54,43 +54,39 @@ module TileBase(botleft_post, topright_post){
     cube([size[0], size[1], tile_th]);
 }
 
-module RoundEdge(left_post, right_post) {
-  length_vec = right_post - left_post;
+m4_dnl  INREFFRAME(left_post, right_post, morevars) { body; }
+m4_define(`INREFFRAME',`
+  length_vec = ($2) - ($1);
   length = dist2d([0,0], length_vec);
   length_uvec = length_vec / length;
   ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
-  m = [ [ length_uvec[0],  ortho_uvec[0], 0, left_post[0], ],
-       [ length_uvec[1],  ortho_uvec[1], 0, left_post[1], ],
+  m = [ [ length_uvec[0],  ortho_uvec[0], 0, ($1)[0], ],
+       [ length_uvec[1],  ortho_uvec[1], 0, ($1)[1], ],
        [ 0,              0,              1,            0, ],
        [ 0,              0,              0,            1, ] ];
-  tlength = length + thehd[1] * 2;
-  multmatrix(m) {
-    translate([-thehd[1], -thehd[0], -round_edge_rad]){
-      difference(){
-       rotate([0,90,0])
-         cylinder(r= round_edge_rad, h= tlength, $fn=50);
-       translate([-1, 0, -20])
-         cube([tlength+2, 20, 20]);
-      }
+  $3
+  multmatrix(m)
+  translate([-thehd[1], -thehd[0], -round_edge_rad])
+')
+
+module RoundEdge(left_post, right_post) {
+  INREFFRAME(left_post, right_post,
+             `tlength = length + thehd[1] * 2;') { m4_dnl '
+    difference(){
+      rotate([0,90,0])
+       cylinder(r= round_edge_rad, h= tlength, $fn=50);
+      translate([-1, 0, -20])
+       cube([tlength+2, 20, 20]);
     }
   }
 }
 
 module RoundLeftCorner(this_post, right_post) {
-  length_vec = right_post - this_post;
-  length_uvec = length_vec - dist2d([0,0], length_vec);
-  ortho_uvec = [ -length_uvec[1], length_uvec[0] ];
-  m = [ [ length_uvec[0],  ortho_uvec[0], 0, this_post[0], ],
-       [ length_uvec[1],  ortho_uvec[1], 0, this_post[1], ],
-       [ 0,              0,              1,            0, ],
-       [ 0,              0,              0,            1, ] ];
-  multmatrix(m) {
-    translate([-thehd[1], -thehd[0], -round_edge_rad]){
-      difference(){
-       sphere(r= round_edge_rad, $fn=60);
-       translate([0,0, -20])
-         cube([20,20,20]);
-      }
+  INREFFRAME(this_post, right_post){
+    difference(){
+      sphere(r= round_edge_rad, $fn=60);
+      translate([0,0, -20])
+       cube([20,20,20]);
     }
   }
 }