Mary asked for a less angular version of the Lip Balm Holder, which gave me a chance to practice my list comprehension:
You hand the OpenSCAD program a list of desired tube diameters in the order you want them, the program plunks the first one (ideally, the largest diameter) in the middle, arranges the others around it counterclockwise from left to right, then slips a lilypad under each tube.
As long as you don’t ask for anything egregiously stupid, the results look reasonably good:
As before, each tube length is 1.5 times its diameter; the lipsticks / balms fit loosely and don’t flop around.
Given the tube diameters and the wall thickness, list comprehensions simplify creating lists of the radii from the center tube to each surrounding tube, the center-to-center distances between each of the outer tubes, and the angles between successive tubes:
// per-tube info, first element forced to 0 to make entries match RawDia vector indexes Radius = [0, for (i=[1:NumTubes-1]) (TubeRad + TubeRad[i] + Wall)]; // Tube[i] distance to center pointRadius = [0, for (i=[1:NumTubes-1]) (TubeRad + 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));
The angles come from the oblique triangle solution when you know all three sides (abc) and want the angle (C) between a and b:
C = arccos( (a2 + b2 - c2) / (2ab) )
Peering down inside, the Slic3r preview shows the lily pads are the tops of squashed spheres:
The pads are 2.0 times the tube diameter, which seemed most pleasing to the eye. They top out at 2.0 mm thick, which might make the edges too thin for comfort.
Update: Here’s what it looks like with a convex hull wrapped around all the lilypads:
I’m awaiting reports from My Spies concerning the typical diameter(s) of lipstick tubes, then I’ll run off a prototype and see about the lily pad edges.
The OpenSCAD source code as a GitHub gist: