Files
phone-case/phone.scad
2023-12-22 02:30:27 +00:00

55 lines
1.5 KiB
OpenSCAD

include <defaults.scad>
include <dimensions.scad>
use <bits.scad>
use <primitives.scad>
// return the kernel which can be convolved with the box body to produce the actual body
module _BodyConvolve(tol=tol) {
minkowski() {
// cylinder rounds the four corners of the phone
cylinder(r=BodyRadXY-BodyRadFrontZ, h=tol, center=true);
// sphere rounds the thickness of the phone
// in actuality this shouldn't be symmetric (the screen and back cover have different radii),
// but using a single radius is Good Enough
sphere(r=BodyRadFrontZ);
// cylinderY(r=BodyRadFrontZ, h=tol, center=true);
// cylinderX(r=BodyRadFrontZ, h=tol, center=true);
}
}
module PhoneBody(Box=false)
{
if (Box) {
cube([BodyWidth, BodyLength, BodyHeight], center=false);
} else {
translate([BodyRadXY, BodyRadXY, BodyRadFrontZ])
minkowski() {
cube([BodyWidth-2*BodyRadXY, BodyLength-2*BodyRadXY, BodyHeight-2*BodyRadFrontZ], center=false);
_BodyConvolve();
}
}
}
module Phone(Box=false, volume=true, power=true, camera=true, usb=true, aux=true)
{
difference() {
union() {
PhoneBody(Box=Box);
if (volume) { Volume(Box=Box); }
if (power) { Power(Box=Box); }
if (camera) { Camera(Box=Box); }
}
union() {
if (usb) { translate([0, tol, 0]) Usb(Box=Box); }
if (aux) { translate([0, -tol, 0]) Aux(); }
}
}
}
Phone();
// debugging:
// translate([0, 0, 20])Phone(Box=true);
// translate([0, 0, 80])BodyConvolve();