@Sanjeev - thanks for running an eye over my code, whilst 3D geometry is
something I can generally figure out, the mathematical side has always
been er, 'a challenge', its not how my brain works :-(. I took a look
at your github PDF, it looks so simple when you explain it like that...
Here is another bit of code I have been developing - it was inspired by
a 3d model I found [somewhere] for a circular box which fits a pringles
can lid. As is not unusual for Thingiverse [or wherever, models], it
was a bit off and lacked a chamfer on the outside edge to make fitting
the lid easier.
So here's my implementation.. uses the same computation for generating
a set of points for a rounded internal corner so I can get small
components out.
Change the diameter and you can make circular boxes [trays?] which fit
any lid from a mini ice cream tub [Haagan Dazs, size = 67], through
coffee tins etc. etc.
The comment on line 42 [where else?] with example 1, will also make a
hexagonal box with a brim which looks user friendly. It would be an
exercise to replace the top with the code at example 4, thus making a
rounded edge to the container A discussion that came up recently.
// Generate list of points in Console for copying to
bezier_cam_paths_v1.scad. X,Y then edited to include Z coordinate for
bezier curve
// see
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/List_Comprehensions
$fa = 2;
$fs = 1;
echo (p1);
outside_od = 78;//pringles
outside_r = 78/2;
inner_radius = 2;
wall_thick = 1;
//inside_rad = 37;//37
chamfer = 0.3;
//wall_z of 10 is OK for testing, but too small to be useful as the lid
overlaps by about half the depth so its harder to remove.
wall_z = 10;//[10:5:30]
lip_thick = 1.8;
lip_height = 1.;
inside_rad = outside_r - lip_thick;
inner_r_offset = inside_rad - inner_radius;
outside_rad = inside_rad + wall_thick;
origin_p = [0,0];
p1 = [[0,0], [0,wall_thick],
for (chi = [270 : 5 : 360]) [(inner_radius * cos(chi))+ inner_r_offset ,
inner_radius * sin(chi)+inner_radius + wall_thick],
[inside_rad,wall_z-chamfer],
[inside_rad+chamfer,wall_z],
[inside_rad+lip_thick-chamfer,wall_z],
[inside_rad+lip_thick,wall_z-chamfer],
[inside_rad+lip_thick,wall_z-chamfer-lip_height],
[outside_rad+chamfer,wall_z-chamfer*3-lip_height],
[outside_rad+chamfer,chamfer],
[outside_rad,0],
];
//Example 1, set $fn to 4 for a square or six for a hex, or remove
altogether for a circle... Coincidentally [not] the diameter of 78
makes a circular box which fits a pringle lid
//rotate_extrude ($fn=4)
//polygon (p1);
//Example 2
//polygon (quarter_circle_p(18,0,30));
steps = 50;
points = [
// first expression generating the points in the positive Y quadrant
for (a = [0 : steps]) [ a, 10 * sin(a * 360 / steps) + 10 ],
// second expression generating the points in the negative Y quadrant
for (a = [steps : -1 : 0]) [ a, 10 * cos(a * 360 / steps) - 20 ],
// additional list of fixed points
[ 10, -3 ], [ 3, 0 ], [ 10, 3 ]
];
//Example 3
//polygon(points);
function circle(radius) = [for (phi = [60 : 10 : 300]) [radius *
cos(phi), radius * sin(phi)]];
//polygon(circle(64));
//echo(circle(64));
function half_circle (radius) = [for (chi = [0 : 10 : 180])
[radius * cos(chi), radius * sin(chi)]];
//Example 4
translate ([60,0,0]) polygon (half_circle(2));
//example 5, add fn=6 and its a hexagonal half circle.
//rotate_extrude() translate ([60,0,0]) polygon (half_circle(2));
function quarter_circle (radius) = [for (chi = [270 : 5 : 360])
[radius * cos(chi), radius * sin(chi)]];
//translate ([0,0,40]) polygon (quarter_circle(8));
function quarter_circle_p (radius,start_angle,end_angle) = [for (chi =
[start_angle : 5 : end_angle])
[radius * cos(chi), radius * sin(chi)]];