Merge pull request 'more stable and accurate dogears' (#1) from better-hinge into main

Reviewed-on: #1
This commit is contained in:
tessak9 2026-04-09 19:47:46 +02:00
commit aa4cd35e41
6 changed files with 33 additions and 9 deletions

View file

@ -1,4 +1,5 @@
// extrusion takes a list of polygons (list of points in 3d space) and connects these into one big polyeder
module extrusion(points){
//points[0] must have its points ordered clockwise
n = len(points);
@ -9,6 +10,12 @@ module extrusion(points){
polyhedron(points = points_new, faces = faces, convexity = 10);
}
//angl_to_ctrl converts a start point, outgoing angle, end point and ingoing angle to control points for a bezier extrusion. to use angl_to_ctrl this file needs to be included, not just used
function angl_to_ctrl (p0, a0, p1, a1, mod = 1) =
let (dist = norm(p1-p0))
[p0,p0+2/3*mod*dist*[cos(a0),sin(a0)],p1+2/3*mod*dist*[cos(a1),sin(a1)],p1];
//ctrl is a list containing 4 control points of the bezier curve. shape is polygon in the 2d plane which is being extruded. mod is a function [0,1] -> |R scaling the shape, mod_x in the x-direction (of the shape), mod_y in the y-direction. if partial is true, then the polyeder is rendered in slices with length given by merlon and gap size given by gap, section defines the number of sections the bezier curve is broken into
module bezier_extrude(ctrl, shape, mod = function (t) 1, mod_x = function(t) 1, mod_y = function (t) 1, partial = false, merlon = 1, gap = 1, sections = 128){
B_0 = ctrl[0];
@ -36,8 +43,8 @@ module bezier_extrude(ctrl, shape, mod = function (t) 1, mod_x = function(t) 1,
}
//some thing to play around with
shape = [[0,0.5],[0.8,0],[0.5,-1],[-0.5,-1],[-0.8,0]];
/*shape = [[0,0.5],[0.8,0],[0.5,-1],[-0.5,-1],[-0.8,0]];
ctrl = [[0,0],[0,20],[20,20],[20,0]];
wave1 = function (x) 0.75+0.25*cos(8*360*x);
wave2 = function (x) 0.75+0.25*sin(8*360*x);
bezier_extrude(ctrl = ctrl, shape = shape, mod_x = wave1, mod_y = wave2, partial = true, merlon = 3, gap = 1, sections = 128);
bezier_extrude(ctrl = angl_to_ctrl([-10,0],90,[10,0],90), shape = shape, mod_x = wave1, mod_y = wave2, partial = true, merlon = 3, gap = 1, sections = 128);*/

View file

@ -1,9 +1,26 @@
use <hinge.scad>;
include <bezier_extrusion.scad>;
//these values were mostly determined by manually finetuning them
t = 5;
a = 41.186; //arctan(7/8)
mod = function (t) 12*t^2*(1-t)^2+1;
ctrl_0 = angl_to_ctrl([-30.5,0]+t*[1,0], 180, [-30.5,0]+t*[-cos(a-25),-sin(a-25)], a-25, mod = 0.5);
ctrl_1 = angl_to_ctrl([-23.6,7]+t*[1,0], 180, [-23.6,7]+t*[-cos(a+180), -sin(a+180)], a+180);
ctrl_2 = angl_to_ctrl([-8,37]+t*[1,0], 180, [-8.5,37]+t*[0,-1], 75, mod = 0.5);
ctrl_3 = angl_to_ctrl([-7.3,44]+t*[1,0], 180, [-7.3,44]+t*[0,1], 270, mod = 0.5);
rectangle_r = [[1.5,0],[1.5,6],[0,6],[0,0]];
rectangle_l = [[0,0],[0,6],[-1.5,6],[-1.5,0]];
//a1, a2, a3, a4 are the four angles of the pairs of hinges on the ear from bottom to tip
module dogearAllOptions(a1, a2, a3, a4){
translate([25,0,0]){
union(){
bezier_extrude(ctrl = ctrl_0, shape = rectangle_r, sections = 8);
bezier_extrude(ctrl = ctrl_1, shape = rectangle_l, mod_x = mod, sections = 8);
bezier_extrude(ctrl = ctrl_2, shape = rectangle_r, mod_x = mod, sections = 8);
bezier_extrude(ctrl = ctrl_3, shape = rectangle_l, mod_x = mod, sections = 8);
//translate([-8,37,0]) cube([10,10,20]);
linear_extrude(height = 6, center = false, convexity = 10){
polygon(points = [[-33,0],[-25,0],[-25,7]]);
}

View file

@ -19,7 +19,7 @@ module hinge(deg, len_before = 0, len_after = 0){
cube([6,7,6], center = false);
polyhedron(points = cut_points, faces = cut_faces, convexity = 10);
translate([3,3.5,3.5]){
rotate(90, [1,0,0]) cylinder(h = 6, r = 2, center = true, $fn = 16);
rotate(90, [1,0,0]) cylinder(h = 5, r = 2, center = true, $fn = 16);
}
if(deg <= 45){
translate([3,2,4.75]){
@ -45,7 +45,7 @@ module hinge(deg, len_before = 0, len_after = 0){
cube([6.5,7,1.5], center = false);
translate([3,3.5,3.5]){
rotate(90, [1,0,0]) cylinder(h = 4.5, r = 1.25, center = true, $fn = 16);
rotate(90, [1,0,0]) cylinder(h = 4, r = 1.5, center = true, $fn = 16);
}
translate([3,2.5,2.25]) cube([4,2,2.5], center = false);
translate([-len_before,0,0]) cube([len_before,7,6], center = false);

View file

@ -2,9 +2,9 @@ use <../base/hinge.scad>;
union(){
translate([7,0,0]) cube([5,47,6]);
hinge(15,0,0);
translate([0,10,0]) hinge(30);
translate([0,20,0]) hinge(45);
translate([0,30,0]) hinge(60);
translate([0,40,0]) hinge(90);
hinge(len_before = 10, 15);
translate([0,10,0]) hinge(len_before = 10, 30);
translate([0,20,0]) hinge(len_before = 10, 45);
translate([0,30,0]) hinge(len_before = 10, 60);
translate([0,40,0]) hinge(len_before = 10, 90);
}

Binary file not shown.

Binary file not shown.