Skip to content

Instantly share code, notes, and snippets.

@boxysean
Created November 25, 2018 19:33
Show Gist options
  • Save boxysean/84422183b2455ea645239de7df10a5b3 to your computer and use it in GitHub Desktop.
Save boxysean/84422183b2455ea645239de7df10a5b3 to your computer and use it in GitHub Desktop.
Bedside dish
// All units inches
function form(length, width, height, thickness) {
return union([
cube({size: [length, thickness, height]}),
cube({size: [length, thickness, height]})
.translate([0, width - thickness, 0]),
cube({size: [thickness, width, height]}),
cube({size: [thickness, width, height]})
.translate([length - thickness, 0, 0])
]);
}
function innerDish(length, width, height, depth, thickness) {
var topPoint = [width/2, width/2, height-depth];
var bottomPoint = [width/2, length - width/2, height-depth];
let rotateNudge = 21;
let translateNudge = 0.0735;
let preRotateNudge = 0.073;
let m = width/2 - 2*thickness;
let l = sqrt(depth*depth + m*m)
let phi = atan(depth / m) - rotateNudge;
console.log([m, l, phi]);
var p1 = rotate(
[-phi, 0, 0],
linear_extrude(
{
height: thickness
},
polygon([
[0, 0],
[length - thickness, 0],
[length - thickness, l],
[0, l]
])
).translate([0, preRotateNudge, 0])
).translate([thickness, 0, height - translateNudge]);
var p2 = rotate(
[phi, 0, 0],
mirror(
[0, 1, 0],
linear_extrude(
{
height: thickness
},
polygon([
[0, 0],
[length - thickness, 0],
[length - thickness, l],
[0, l]
])
).translate([0, preRotateNudge, 0])
)
).translate([thickness, width, height - translateNudge]);
return union([p1, p2]);
}
function main() {
var length = 4;
var width = 1.5;
var height = 1.5;
var depth = 0.6;
var thickness = 0.125;
return union([
form(length, width, height, thickness),
innerDish(length, width, height, depth, thickness)
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment