63 lines
1.4 KiB
OpenSCAD
63 lines
1.4 KiB
OpenSCAD
|
|
// Lampshade
|
|
|
|
|
|
$fn=128;
|
|
|
|
function f(z) = 0.145 + .1 * sin(1.22 * z) + .06 * cos(.97 * z);
|
|
|
|
vase_height = 195;
|
|
vase_radius = 270;
|
|
step = 1;
|
|
twist = 1.4;
|
|
|
|
sh3_nodes = 4;
|
|
|
|
|
|
|
|
//sh3 = [0,30,60,90,120,180,210,240,270,300,330,360]; // polygon being extruded
|
|
sh3 = [ for (i = [1:sh3_nodes]) i*(360/sh3_nodes) ];
|
|
|
|
|
|
p = [
|
|
for (z = [0:step:vase_height], angle = sh3) [
|
|
vase_radius*cos(angle+twist*z)*f(z),
|
|
vase_radius*sin(angle+twist*z)*f(z),
|
|
z
|
|
]
|
|
];
|
|
|
|
|
|
module shape(p,m,n) {
|
|
fcs = [for (j = [1:m], i = [0:n-2])[(n*j)+i,(n*j)+1+i,(n*(j-1))+i+1,(n*(j-1))+i]];
|
|
|
|
top = [for (i = [n*m:(n*m)+n-1]) i]; //connect points to create the top face
|
|
|
|
bottom = [for (i = [0:n-1]) i]; //connect points to create the bottom
|
|
|
|
stitches = [for (j = [0:m-1]) [j*n,((j+1)*n)-1,(((j+2)*n)-1),(j+1)*n]]; //connect points between the first and the last face per row
|
|
|
|
//now connect all
|
|
//reverse is used to reverse normal of top face
|
|
fcsc = concat([bottom],fcs,stitches,[reverse(top)]); //concatenate the bottom, body and top
|
|
|
|
color("blue") polyhedron(points=p, faces=fcsc);
|
|
}
|
|
|
|
function reverse(lt) = [for(i = len(lt) - 1; i > -1; i = i - 1) lt[i]];
|
|
|
|
m = floor(vase_height/step); //numbers of rows of the matrix
|
|
n = len(sh3); //number of columns in the matrix
|
|
|
|
for ( i = [0 : 23] ) {
|
|
rotate([0,0,15*i])
|
|
shape(p,m,n);
|
|
};
|
|
|
|
|
|
mirror([1,0,0])
|
|
for ( i = [0 : 23] ) {
|
|
rotate([0,0,15*i])
|
|
shape(p,m,n);
|
|
};
|
|
|