lampshade/lampshade.scad

105 lines
1.8 KiB
OpenSCAD
Raw Normal View History

2024-05-11 10:39:25 +02:00
// Thickness.
th = 1;
// Bottom thickness.
bottom = 1;
// Inner radius.
mount = 14.5;
// Outer radius.
rad = 40;
// Incline (percent).
inc = 20;
// Height.
height = 90;
// Curve intensity.
ci = 3;
$fn = 6;
// Mount.
difference() {
cylinder(h=bottom, r=mount+12);
cylinder(h=bottom, r=mount, $fn=32);
}
// Struts.
intersection() {
for(rot=[0:360/6:359]) {
rotate([0, 0, rot]) {
translate([mount, -bottom*4, 0])
cube([rad-mount, bottom*8, bottom]);
translate([mount+8, -bottom/2, 0])
cube([rad-mount, bottom, bottom*4]);
}
}
outer_shade();
}
// Upper end of shade.
difference() {
cylinder(h=bottom, r=rad);
cylinder(h=bottom, r=rad-(rad*0.1));
}
// Shade curve.
/*curve = [
0,
-0.25,
-0.375,
-0.25,
0,
0.5,
0.75,
0.875,
0.75,
0.5,
0,
];*/
curve = [
0,
0.5,
0.75,
0.875,
0.9375,
0.96875,
0.9375,
0.875,
0.75,
0.5,
0,
];
// Shade.
// Construct from 9 seqments of 1/10 length.
module outer_shade() {
for(i=[0:9]) {
z = height/10 * i;
r1 = rad + i * ((rad*inc/50*height/100)/10) + (ci*curve[i]);
r2 = rad + (i+1) * ((rad*inc/50*height/100)/10) + (ci*curve[i+1]);
// 10 segments.
translate([0, 0, z])
cylinder(h=height/10, r1=r1, r2=r2);
}
}
module inner_shade() {
for(i=[0:9]) {
z = height/10 * i;
r1 = rad + i * ((rad*inc/50*height/100)/10) + (ci*curve[i]) - th;
r2 = rad + (i+1) * ((rad*inc/50*height/100)/10) + (ci*curve[i+1]) - th;
// 10 segments.
translate([0, 0, z])
cylinder(h=height/10, r1=r1, r2=r2);
}
}
// The shade.
difference() {
outer_shade();
inner_shade();
}