chiark / gitweb /
earring-stand: wip main Demo
[reprap-play.git] / earring-stand.scad
index 60b5199e858894be97f460e89e1912fd6fedb9a7..63cf8c6f5d87ca44c963a4853abb37ed132ca8cc 100644 (file)
@@ -1,5 +1,11 @@
 // -*- C -*-
 
+include <commitid.scad>
+
+front_height = 80;
+front_width = 120;
+front_setback = 30;
+
 eclip_inner_rad = 2.5;
 eclip_gap_rad = 0.5;
 eclip_prong_th = 3;
@@ -36,6 +42,8 @@ rgap = eclip_gap_rad;
 eclip_base_offset = r1;
 eclip_wall_offset = -ppxl;
 
+eclip_ra_offset = r2 - 0.1;
+
 $fn=70;
 
 module EclipLPlanCore(alpha){
@@ -80,7 +88,7 @@ module EclipPPlan(main_th){
   translate([ppxl, 0]) square([main_th, r2]);
 }
 
-module TestBase(){
+module TestBase(){ ////toplevel
   translate([0,0, eclip_base_offset]){
     for (i=[0 : 2: test_eclips-1]) {
       translate([0, i*eclip_each_every])
@@ -95,25 +103,90 @@ module TestBase(){
        EclipRPlan(test_alpha, test_main_th);
     }
   }
-  translate([-r2, -eclip_each_len, -test_base_th])
-    cube([r2*2,
-         test_len,
-         test_base_th]);
+  translate([-r2, -eclip_each_len, -test_base_th]){
+    difference(){
+      cube([r2*2,
+           test_len,
+           test_base_th]);
+      mirror([0,0,1]) Commitid_BestCount_M([r2*2, test_len]);
+    }
+  }
 }
 
-module TestProtr(){
-  translate([0,0, test_main_th - eclip_wall_offset])
-    rotate([0,90,0])
-    linear_extrude(height=test_len)
-    EclipPPlan(test_main_th);
+module TestProtr(){ ////toplevel
+  difference(){
+    translate([0,0, test_main_th - eclip_wall_offset])
+      rotate([0,90,0])
+      linear_extrude(height=test_len)
+      EclipPPlan(test_main_th);
+    mirror([0,0,1]) Commitid_BestCount_M([test_len, r2]);
+  }
+}
+
+module TestRAProtr(){ ////toplevel
+  rotate([-90,0,0]) TestProtr();
+  mirror([1,0,0])
+    translate([-test_len,
+              -r2,
+              -(eclip_ra_offset + test_base_th)])
+    cube([test_len,
+         r2*2,
+         test_base_th]);
 }
 
-module PlanDemo(){
+module TestPlanDemo(){
   color("red") EclipLPlan(test_alpha);
   color("blue") rotate(test_alpha) EclipPPlan(test_main_th);
   color("green") EclipRPlan(test_alpha, test_main_th);
 }
 
+beta = asin(front_setback / front_height);
+
+uf = [-sin(beta), cos(beta)];
+ur = [-uf[0], uf[1]];
+
+pp = [0, 0];
+pq = pp + uf*front_height + ur*eclip_ra_offset;
+pr = [ pq[0] - eclip_base_offset + eclip_wall_offset, 0 ];
+
+module Sketch(){
+  polygon([pq, pp, pr]);
+}
+
+thicks = [ 2, 2, 2 ];
+
+module Joins(alpha, objnum, objnum_f, objnum_m) {
+  echo("Joins",objnum, objnum_f, objnum_m);
+  thm = thicks[objnum_m];
+  if (objnum==objnum_f) {
+    EclipLPlan(alpha);
+    EclipRPlan(alpha, thm);
+  }
+  if (objnum==objnum_m)
+    rotate(alpha)
+      EclipPPlan(thm);
+}
+
+module Object(objnum){
+  echo("Object",objnum);
+  translate(pp)                  Joins(beta, objnum, 0,1);
+  translate(pr) mirror([1,0,0])  Joins(0,    objnum, 0,2);
+  translate(pq) rotate([0,0,90]) Joins(beta, objnum, 2,1);
+}
+
+module Base(){ Object(0); }
+module Front(){ Object(1); }
+module Back(){ Object(2); }
+
+module Demo(){
+  Base();
+  Front();
+  Back();
+}
+
 //PlanDemo();
 //TestBase();
-TestProtr();
+//TestProtr();
+//TestRAProtr();
+//Sketch();
+Demo();