From 7201d83ebe70f780ccbca054430b96b579ff042b Mon Sep 17 00:00:00 2001 From: tessaK9 Date: Wed, 11 Mar 2026 10:22:22 +0100 Subject: [PATCH] started working on bezier extrusion, slightly updated dogear flopness --- bezierExtrusion.scad | 41 +++++++++++++++++++++++++++++++++++++++++ dogear.scad | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 bezierExtrusion.scad diff --git a/bezierExtrusion.scad b/bezierExtrusion.scad new file mode 100644 index 0000000..e493e37 --- /dev/null +++ b/bezierExtrusion.scad @@ -0,0 +1,41 @@ +module section(points){ + //points[0] must have its points ordered clockwise + assert(len(points) == 2, "section is formed between exactly two polygons"); + assert(len(points[0]) == len(points[1]), "polygons need to have the same number of vertices"); + assert(len(points[0])>2, "polygons need to have at least 3 sides"); + n = len(points[0]); + points_new = concat(points[0], points[1]); + faces = concat([[for(i = [0 : 1 : n-1]) i]], concat([[for(i = [1 : n]) (2*n)-i]], concat( + [for(i = [0 : n-2]) [i+1, i, n+i, n+i+1]], [[0,n-1,(2*n)-1,n]]))); + polyhedron(points = points_new, faces = faces, convexity = 10); +} + +module extrusion(points){ + assert(len(points)>1, "extrusion is formed between at least two polygons"); + for(i = [0 : len(points)-2]) section([points[i],points[i+1]]); +} + +module bezier_extrude(ctrl, shape, steps = 512){ + B_0 = ctrl[0]; + B_1 = 3*((-1)*ctrl[0] + ctrl[1]); + B_2 = 3*(ctrl[0] - 2*ctrl[1] + ctrl[2]); + B_3 = (-1)*ctrl[0] + 3*(ctrl[1] - ctrl[2]) + ctrl[3]; + function bezier(t) = B_0 + t*B_1 + (t^2)*B_2 + (t^3)*B_3; + + Bd_0 = 3*((-1)*ctrl[0] + ctrl[1]); + Bd_1 = 6*(ctrl[0] - 2*ctrl[1] + ctrl[2]); + Bd_2 = 3*((-1)*ctrl[0] + 3*(ctrl[1] - ctrl[2]) + ctrl[3]); + Bn_0 = [Bd_0.y,-Bd_0.x]; + Bn_1 = [Bd_1.y,-Bd_1.x]; + Bn_2 = [Bd_2.y,-Bd_2.x]; + function normal(t) = Bn_0 + t*Bn_1 + (t^2)*Bn_2; + + slices = [for(i = [0 : steps]) let (t = i/steps, p = bezier(t), normal = normal(t), n = normal/norm(normal)) [for (v = shape) [p.x+(n.x * v.x),p.y+(n.y * v.x), v.y]]]; + extrusion(slices); +} + +shape = [[0,0.5],[0.8,0],[-0.5,-1],[-0.8,0]]; +ctrl = [[0,0],[0,10],[10,0],[10,10]]; +bezier_extrude(ctrl = ctrl, shape = shape); + +//extrusion([[[0,0,0],[0,1,0],[0,1,1],[0,0,1]],[[1,0,0],[1,1,0],[1,1,1],[1,0,1]],[[2,0,1],[2,1,1],[2,1,2],[2,0,2]]]); \ No newline at end of file diff --git a/dogear.scad b/dogear.scad index 415094c..ba3ff66 100644 --- a/dogear.scad +++ b/dogear.scad @@ -84,7 +84,7 @@ module dogear(flopness){ dogearAllOptions(a1, a2, a3, a4); } else{ - if(flopness == "nflop"){ + if(flopness == "lflop"){ a1 = 15; a2 = 15; a3 = 15;