added partial extrusion for faster headband rakes, small changes
This commit is contained in:
parent
7ab5da4b45
commit
dcef9ae8b9
4 changed files with 55 additions and 17 deletions
|
|
@ -3,10 +3,38 @@ module extrusion(points){
|
||||||
n = len(points);
|
n = len(points);
|
||||||
k = len(points[0]);
|
k = len(points[0]);
|
||||||
points_new = [for(L = points) for(p = L) p];
|
points_new = [for(L = points) for(p = L) p];
|
||||||
faces = concat([[for(i = [0 : k-1]) i], [for(i = [1 : k]) (n*k)-i]], concat([for (i = [0 : n-2]) for (j = [0 : k-2]) [(i*k)+j+1, (i*k)+j, ((i+1)*k)+j, ((i+1)*k)+j+1]], [for (i = [0 : n-2]) [i*k,(i+1)*k-1,((i+2)*k)-1,(i+1)*k]]));
|
faces = concat([[for(i = [0 : k-1]) i], [for(i = [1 : k]) (n*k)-i]],
|
||||||
|
concat([for (i = [0 : n-2]) for (j = [0 : k-2]) [(i*k)+j+1, (i*k)+j, ((i+1)*k)+j, ((i+1)*k)+j+1]], [for (i = [0 : n-2]) [i*k,(i+1)*k-1,((i+2)*k)-1,(i+1)*k]]));
|
||||||
polyhedron(points = points_new, faces = faces, convexity = 10);
|
polyhedron(points = points_new, faces = faces, convexity = 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module slice(points){
|
||||||
|
k = len(points[0]);
|
||||||
|
points_new = [for(L = points) for(p = L) p];
|
||||||
|
faces = concat([[for(i = [0 : k-1]) i], [for(i = [1 : k]) 2*k-i], [0,k-1,(2*k)-1,k]], [for (i = [0 : k-2]) [i+1, i, k+i, k+i+1]]);
|
||||||
|
polyhedron(points = points_new, faces = faces, convexity = 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
module bezier_extrude_partial(ctrl, shape, gap = 1, mod = function (t) 1, mod_x = function(t) 1, mod_y = function (t) 1, sections = 128){
|
||||||
|
B_0 = ctrl[0];
|
||||||
|
B_1 = 3*(-ctrl[0] + ctrl[1]);
|
||||||
|
B_2 = 3*(ctrl[0] - 2*ctrl[1] + ctrl[2]);
|
||||||
|
B_3 = -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;
|
||||||
|
|
||||||
|
Bn_0 = [B_1.y,-B_1.x];
|
||||||
|
Bn_1 = [2*B_2.y,(-2)*B_2.x];
|
||||||
|
Bn_2 = [3*B_3.y,(-3)*B_3.x];
|
||||||
|
function normal(t) = Bn_0 + t*Bn_1 + (t^2)*Bn_2;
|
||||||
|
|
||||||
|
slices = [for (i = [0 : sections])
|
||||||
|
let (t = i/sections, p = bezier(t), normal = normal(t), n = normal/norm(normal))
|
||||||
|
[for (v = shape) [p.x+(mod(t) * mod_x(t) * n.x * v.x),p.y+(mod(t) * mod_x(t) * n.y * v.x), mod(t) * mod_y(t) * v.y]]];
|
||||||
|
for(i = [0 : 1+gap : sections-1]){
|
||||||
|
slice([slices[i],slices[i+1]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module bezier_extrude(ctrl, shape, mod = function (t) 1, mod_x = function(t) 1, mod_y = function (t) 1, sections = 128){
|
module bezier_extrude(ctrl, shape, mod = function (t) 1, mod_x = function(t) 1, mod_y = function (t) 1, sections = 128){
|
||||||
B_0 = ctrl[0];
|
B_0 = ctrl[0];
|
||||||
B_1 = 3*(-ctrl[0] + ctrl[1]);
|
B_1 = 3*(-ctrl[0] + ctrl[1]);
|
||||||
|
|
@ -28,4 +56,4 @@ module bezier_extrude(ctrl, shape, mod = function (t) 1, mod_x = function(t) 1,
|
||||||
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],[20,10],[0,20],[10,0]];
|
ctrl = [[0,0],[20,10],[0,20],[10,0]];
|
||||||
wave = function (x) 0.75+0.25*cos(3*360*x);
|
wave = function (x) 0.75+0.25*cos(3*360*x);
|
||||||
bezier_extrude(ctrl = ctrl, shape = shape, mod = wave, sections = 8192);
|
bezier_extrude_partial(ctrl = ctrl, shape = shape, mod = wave, sections = 32);
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use <bezier_extrusion.scad>;
|
use <bezier_extrusion.scad>;
|
||||||
use <headband.scad>;
|
use <headband.scad>;
|
||||||
|
|
||||||
thickness = 2.5;
|
thickness = 2.7;
|
||||||
height = 5.5;
|
height = 5.5;
|
||||||
|
|
||||||
module catear(){
|
module catear(){
|
||||||
|
|
@ -17,10 +17,9 @@ module catear(){
|
||||||
[-thickness/2,height/2-0.5],
|
[-thickness/2,height/2-0.5],
|
||||||
[-thickness/2+0.5,height/2],
|
[-thickness/2+0.5,height/2],
|
||||||
[thickness/2-0.5,height/2]];
|
[thickness/2-0.5,height/2]];
|
||||||
union(){
|
|
||||||
bezier_extrude(ctrl = ctrl_ear1, shape = shape_band, sections = 32);
|
bezier_extrude(ctrl = ctrl_ear1, shape = shape_band, sections = 32);
|
||||||
bezier_extrude(ctrl = ctrl_ear2, shape = shape_band, sections = 32);
|
bezier_extrude(ctrl = ctrl_ear2, shape = shape_band, sections = 32);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module catears(){
|
module catears(){
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use <headband.scad>;
|
use <headband.scad>;
|
||||||
use <dogear.scad>;
|
use <dogear.scad>;
|
||||||
|
|
||||||
thickness = 2.5;
|
thickness = 2.7;
|
||||||
|
|
||||||
module dogears(rightear = "flop", leftear = "flop"){
|
module dogears(rightear = "flop", leftear = "flop"){
|
||||||
union() {
|
union() {
|
||||||
|
|
@ -21,4 +21,4 @@ module dogears(rightear = "flop", leftear = "flop"){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dogears(rightear = "lflop");
|
dogears();
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use <bezier_extrusion.scad>;
|
use <bezier_extrusion.scad>;
|
||||||
|
|
||||||
module headband(thickness, height){
|
module headband(thickness, height){
|
||||||
rake_length = 2.5;
|
rake_length = 3;
|
||||||
|
|
||||||
shape_band = [[thickness/2,height/2-0.5],
|
shape_band = [[thickness/2,height/2-0.5],
|
||||||
[thickness/2,-height/2+0.5],
|
[thickness/2,-height/2+0.5],
|
||||||
|
|
@ -16,20 +16,31 @@ module headband(thickness, height){
|
||||||
[0,height/2],
|
[0,height/2],
|
||||||
[rake_length,height/2-2],
|
[rake_length,height/2-2],
|
||||||
[rake_length,-height/2+2]];
|
[rake_length,-height/2+2]];
|
||||||
|
|
||||||
|
shape_halfband = [[thickness/2,height/2-0.5],
|
||||||
|
[thickness/2,-height/2+0.5],
|
||||||
|
[thickness/2-0.5,-height/2],
|
||||||
|
[0,-height/2],
|
||||||
|
[0,height/2],
|
||||||
|
[thickness/2-0.5,height/2]];
|
||||||
|
|
||||||
ctrl_band = [[21,0],[77,56],[56,126],[0,126]];
|
ctrl_band = [[21,0],[77,56],[56,126],[0,126]];
|
||||||
ctrl_end = [[21,0],[20,-1],[18,-4],[17,-10]];
|
ctrl_end = [[21,0],[20,-1],[18,-4],[17,-8]];
|
||||||
ctrl_rake = [[-52,86],[-40,139.5],[40,139.5],[52,86]];
|
ctrl_rake = [[-52,86],[-40,139.5],[40,139.5],[52,86]];
|
||||||
fillet = function (t) (t < 0.75) ? 1 : sqrt(1-((4*t)-3)^2)/1.5 + 0.33;
|
|
||||||
rake = function (t) (-cos(64 * 360 * t) > 0.33) ? 1 : 0.1;
|
|
||||||
|
|
||||||
union(){
|
union(){
|
||||||
bezier_extrude(ctrl = ctrl_band, shape = shape_band, sections = 64);
|
bezier_extrude(ctrl = ctrl_band, shape = shape_band, sections = 64);
|
||||||
mirror([1,0,0]) bezier_extrude(ctrl = ctrl_band, shape = shape_band, sections = 64);
|
mirror([1,0,0]) bezier_extrude(ctrl = ctrl_band, shape = shape_band, sections = 64);
|
||||||
bezier_extrude(ctrl = ctrl_end, shape = shape_band, mod_x = fillet, sections = 16);
|
bezier_extrude(ctrl = ctrl_end, shape = shape_band, sections = 16);
|
||||||
mirror([1,0,0]) bezier_extrude(ctrl = ctrl_end, shape = shape_band, mod_x = fillet, sections = 16);
|
translate([17,-8]){
|
||||||
bezier_extrude(ctrl = ctrl_rake, shape = shape_rake, mod_x = rake, sections = 512);
|
rotate_extrude(convexity = 10, $fn = 16) polygon(shape_halfband);
|
||||||
|
}
|
||||||
|
mirror([1,0,0]) bezier_extrude(ctrl = ctrl_end, shape = shape_band, sections = 16);
|
||||||
|
translate([-17,-8]){
|
||||||
|
rotate_extrude(convexity = 10, $fn = 16) polygon(shape_halfband);
|
||||||
|
}
|
||||||
|
bezier_extrude_partial(ctrl = ctrl_rake, shape = shape_rake, gap = 2, sections = 3*64+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
headband(thickness = 2.5, height = 5.5);
|
headband(thickness = 2.7, height = 5.5);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue