Last active
February 11, 2016 23:11
-
-
Save ednisley/6d25fc03940ce0775529 to your computer and use it in GitHub Desktop.
OpenSCAD Source Code: Improved Lipstick and Lip Balm Holder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lipstick and Balm Tube Holder | |
// Ed Nisley KE4ZNU - February 2016 | |
//- Extrusion parameters - must match reality! | |
ThreadThick = 0.25; | |
ThreadWidth = 0.40; | |
function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit); | |
Protrusion = 0.1; | |
HoleWindage = 0.2; | |
//------ | |
// Dimensions | |
RawDia = [26,21,19,17,19,21]; // actual tube diameters in desired order, center = largest first | |
NumTubes = len(RawDia); | |
Clearance = 2.0; | |
TubeDia = [for (i=[0:NumTubes-1]) (RawDia[i] + Clearance)]; // actual tube diameters | |
TubeRad = TubeDia / 2; | |
echo(str("NumTubes: ",NumTubes)); | |
Wall = 2.0; | |
BaseThick = 2.0; | |
BaseFactor = 2.0; | |
NumSides = 8*4; | |
// per-tube info, first element forced to 0 to make entries match RawDia vector indexes | |
Radius = [0, for (i=[1:NumTubes-1]) (TubeRad[0] + TubeRad[i] + Wall)]; // Tube[i] distance to center point | |
echo(str("Radius: ",Radius)); | |
CtrToCtr = [0, for (i=[1:NumTubes-2]) (TubeRad[i] + TubeRad[i+1] + Wall)]; // Tube[i] distance to Tube[i+1] | |
echo(str("CtrToCtr: ",CtrToCtr)); | |
Angle = [0, for (i=[1:NumTubes-2]) acos((pow(Radius[i],2) + pow(Radius[i+1],2) - pow(CtrToCtr[i],2)) / (2 * Radius[i] * Radius[i+1]))]; | |
echo(str("Angle: ",Angle)); | |
TotalAngle = sumv(Angle,len(Angle)-1); | |
echo(str("TotalAngle: ",TotalAngle)); | |
//---------------------- | |
// Useful routines | |
// vector sum cribbed from doc | |
function sumv(v,i,s=0) = (i==s ? v[i] : v[i] + sumv(v,i-1,s)); | |
//---------------------- | |
//- Build it | |
for (i=[0:NumTubes-1]) | |
rotate(90 - TotalAngle/2 + sumv(Angle, (i>0) ? (i-1) : 0)) | |
translate([Radius[i],0,0]) { | |
resize([0,0,2*BaseThick]) // bases | |
difference() { | |
sphere(r=BaseFactor*TubeRad[i],$fn=NumSides); | |
translate([0,0,-BaseFactor*TubeDia[i]]) | |
cube(2*BaseFactor*TubeDia[i],center=true); | |
} | |
difference() { // tubes | |
cylinder(r=TubeRad[i] + Wall,h=1.5*TubeDia[i] + BaseThick,$fn=NumSides); | |
cylinder(d=TubeDia[i],h=1.5*TubeDia[i] + BaseThick + Protrusion,$fn=NumSides); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More details on my blog at http://wp.me/poZKh-5Dq