+function Rectangle_corners(c0, sz) =
+ // returns the corners of a rectangle from c0 to c0+sz
+ // if sz is positive, the corners are anticlockwise starting with c0
+ [ c0 + [ 0, 0 ],
+ c0 + [ sz[0], 0 ],
+ c0 + [ sz[0], sz[1] ],
+ c0 + [ 0, sz[1] ] ];
+
+function Rectangle_corners2posts(c) =
+ [ c[0] + thehd_tr,
+ c[1] + thehd_tl,
+ c[2] + thehd_bl,
+ c[3] + thehd_br ];
+
+module Tile02(){ ////toplevel
+ sz = [100,170];
+ c0 = -sz;
+ c = Rectangle_corners(c0, sz);
+ posts = Rectangle_corners2posts(c);
+ rcs = [c[0], c[1]];
+ difference(){
+ union(){
+ TileBase(c[0], c[2]);
+ Posts(posts);
+ RoundEdge(c[0], c[1]);
+ RoundEdge(c[3], c[0]);
+ InterlockEdge(c[2], c[3], 0);
+ }
+ InterlockEdge(c[1], c[2], 1);
+ RoundCornerCut(rcs);
+ }
+ RoundCornerAdd(rcs);
+}
+
+module Tile12(){ ////toplevel
+ sz = [100,250];
+ c0 = [-sz[0], 0];
+ c = Rectangle_corners(c0, sz);
+ posts = Rectangle_corners2posts(c);
+ rcs = [c[3], c[0]];
+ difference(){
+ union(){
+ TileBase(c[0], c[2]);
+ RoundEdge(c[2], c[3]);
+ RoundEdge(c[3], c[0]);
+ Posts(posts);
+ }
+ InterlockEdge(c[0], c[1], 1);
+ RoundCornerCut(rcs);
+ }
+ RoundCornerAdd(rcs);
+}
+
+module Demo(){ ////toplevel
+ translate(demo_slop*[-2,1]) color("blue") Tile12();
+ translate(demo_slop*[-2,0]) color("red") Tile02();
+}
+