From 519a41c7a4232db4223cbc08a067771bf699a448 Mon Sep 17 00:00:00 2001 From: djerun Date: Sun, 15 Jun 2025 16:30:38 +0200 Subject: [PATCH] [WIP][DEBUG] --- bezier_circle_approximation.scad | 15 ++++++++++ headband.scad | 2 +- pressfit_bunnyears.scad | 50 ++++++++++++++++++-------------- pressfit_catears.scad | 28 ++++++++++++++++-- 4 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 bezier_circle_approximation.scad diff --git a/bezier_circle_approximation.scad b/bezier_circle_approximation.scad new file mode 100644 index 0000000..fd404d2 --- /dev/null +++ b/bezier_circle_approximation.scad @@ -0,0 +1,15 @@ +a=90; + +module bezier_curve(p0, p1, p2, p3) { + // TODO +} + +module /*TODO*/ { + c = /*TODO*/; + bezier_curve( + [0, 1], + [c, 1], + [1, c], + [1, 0] + ); +} diff --git a/headband.scad b/headband.scad index 53465e7..768ea3a 100644 --- a/headband.scad +++ b/headband.scad @@ -4,7 +4,7 @@ use module headband(debug=DEBUG, size=SIZE, height=HEIGHT, thickness=THICKNESS, part=PART, stretch_len=STRETCH_LEN, tip_len=TIP_LEN, tip_bend=TIP_BEND, rake_depth=RAKE_DEPTH, rake_width=RAKE_WIDTH, rake_stretch=RAKE_STRETCH, rake_chamfer=RAKE_CHAMFER, chamfer=CHAMFER, chamfer_shape=CHAMFER_SHAPE, with_rake=true, details=true) { union() { - chamfer(size=(details)?chamfer:0, child_h=height, child_bot=-height/2, shape=chamfer_shape) union() { + /*chamfer(size=(details)?chamfer:0, child_h=height, child_bot=-height/2, shape=chamfer_shape)*/ union() { color("purple") partial_ring(part, radius=size, thickness=thickness, height=height); rotate( 90-180*part, [0, 0, 1]) diff --git a/pressfit_bunnyears.scad b/pressfit_bunnyears.scad index 7a34637..9c64e2b 100644 --- a/pressfit_bunnyears.scad +++ b/pressfit_bunnyears.scad @@ -8,30 +8,38 @@ $fn=90; EAR_SCALE = 0.5; EAR_BEND_FACTOR = 0.2; EAR_STRETCH_FACTOR = 8; -STEP_SIZE = .5; +STEP_SIZE = .25; + + +module loop(i) { + j=pow(0.99, i); + //chamfer_ = floor(abs(2*i/(SIZE/2*EAR_SCALE-1)-1)); + translate([-j*20, 0, 0]) + difference() { + rotate(90, [0, 1, 0]) + /*chamfer(size=1, child_h=1, child_bot=-0.5, shape=CHAMFER_SHAPE)*/ { + //echo("i", i, "j", j, "chamfer_", chamfer_); + union() catear( + debug=DEBUG, + height=INSERTICLE_Z*1.2, + thickness=THICKNESS, + side_len=SIZE/2*EAR_SCALE-i, + bend_factor=EAR_BEND_FACTOR, + stretch_factor=EAR_STRETCH_FACTOR, + chamfer=0, //chamfer_, + chamfer_shape=CHAMFER_SHAPE, + details=false, + end_caps=true + ); + } + cube([100, 100, THICKNESS], center=true); + } +} //difference() { translate([20*pow(0.99, SIZE/2*EAR_SCALE-1-THICKNESS), 0, -THICKNESS/2]) - /*union()*/ for (i=[0:STEP_SIZE:SIZE/2*EAR_SCALE-1]) { - j=pow(0.99, i); - chamfer_ = floor(abs(2*i/(SIZE/2*EAR_SCALE-1)-1)); - translate([-j*20, 0, 0]) - rotate(90, [0, 1, 0]) - /*chamfer(size=1, child_h=1, child_bot=-0.5, shape=CHAMFER_SHAPE)*/ { - echo("i", i, "j", j, "chamfer_", chamfer_); - catear( - debug=DEBUG, - height=INSERTICLE_Z*1.2, - thickness=THICKNESS, - side_len=SIZE/2*EAR_SCALE-i, - bend_factor=EAR_BEND_FACTOR, - stretch_factor=EAR_STRETCH_FACTOR, - chamfer=0, //chamfer_, - chamfer_shape=CHAMFER_SHAPE, - details=false, - end_caps=false - ); - } + union() for (i=[0:STEP_SIZE:0/*SIZE/2*EAR_SCALE-1*/]) { + loop(i); } // translate([0, 0, -THICKNESS]) cube([100, 100, THICKNESS], center=true); // scale([1, 1, 2]) inserticle(); diff --git a/pressfit_catears.scad b/pressfit_catears.scad index 4fbeafe..05e2a41 100644 --- a/pressfit_catears.scad +++ b/pressfit_catears.scad @@ -1,5 +1,7 @@ include ; +include ; +use ; use ; use ; use ; @@ -7,9 +9,9 @@ use ; EAR_SCALE = 1.5; EAR_BEND_FACTOR = 0.15; EAR_STRETCH_FACTOR = 1.2; -STEP_SIZE = 1; +STEP_SIZE = 100; -difference() { +translate([50, 0, 0]) difference() { translate([20*pow(0.99, SIZE/2*EAR_SCALE-1-THICKNESS), 0, -THICKNESS/2]) union() for (i=[0:STEP_SIZE:SIZE/2*EAR_SCALE-1]) { j=pow(0.99, i); @@ -32,3 +34,25 @@ difference() { translate([0, 0, -THICKNESS]) cube([100, 100, THICKNESS], center=true); scale([1, 1, 2]) inserticle(); } + +side_len=SIZE/2*EAR_SCALE; +r=side_len/2; +E=1.6*EAR_STRETCH_FACTOR; +e=E*(r+THICKNESS/4)/(r-THICKNESS/4); +T=side_len+THICKNESS; +S=side_len-THICKNESS; +xremap = function (x) pow(x, EAR_STRETCH_FACTOR); +yremap = function (y) pow(y, 1); +//f = function (p) [j((p.x+T/2)/T)*T-T/2, pow(p.y, 2)/r*E, p.z]; +//g = function (p) [j((p.x+S/2)/S)*S-S/2, pow(p.y, 2)/r*E*(T+THICKNESS)/S, p.z]; +f = function (p) [scalc(xremap, p.x, -T/2, T/2), scalc(yremap, p.y, 0, T/2)*E, p.z]; +g = function (p) [scalc(xremap, p.x, -S/2, S/2), scalc(yremap, p.y, 0, S/2)*e, p.z]; + +rotate([0, 90, 0]) color("yellow") arc(0.5, r, THICKNESS, HEIGHT, outer_remap=f, inner_remap=g); + +color("red") catear_v2(HEIGHT, THICKNESS, side_len=SIZE/2*EAR_SCALE, stretch_factor=EAR_STRETCH_FACTOR); + +// a = b + c +// x * a = y * b + c +// y / x = a /(b + c) +// y = x * a /(b + c)