Can someone please help me with this math? My brain stopped braining.
I have a polygon with N sides, and a width of D, which is measured
flat-to-flat through the center.
I want to create an OpenSCAD cylinder() of the correct radius and a $FN of
N that is the same shape as the polygon.
Can anyone help me with this math?
Radius of the circle , r = D/(2*cos(theta/2))
Where theta = 360/N
On Wed, 23 Aug, 2023, 9:10 am Bryan Lee, leebc11@acm.org wrote:
Can someone please help me with this math? My brain stopped braining.
I have a polygon with N sides, and a width of D, which is measured
flat-to-flat through the center.
I want to create an OpenSCAD cylinder() of the correct radius and a $FN of
N that is the same shape as the polygon.
Can anyone help me with this math?
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
If using BOSL2, you can just do:
cyl(h=H, d=D, $fn=N, circum=true);
or, if you want the faces aligned with the axes:
cyl(h=H, d=D, $fn=N, circum=true, realign=true);
On Aug 22, 2023, at 8:39 PM, Bryan Lee leebc11@acm.org wrote:
Can someone please help me with this math? My brain stopped braining.
I have a polygon with N sides, and a width of D, which is measured
flat-to-flat through the center.
I want to create an OpenSCAD cylinder() of the correct radius and a $FN of
N that is the same shape as the polygon.
Can anyone help me with this math?
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Here’s my library module that includes that information. PolyCyl produces an N sided cyclinder with a variety of different inputs, depending on what you know.
-Bob
Tucson AZ
/*
polyCyl
Produce a "cylinder" with n sides
id - face to face
od - diameter of circumscribed circle
side - the length of one side
h or l - length of cylinder
tent - size of "tents" on both ends
Id, od and side are mutually exclusive. default is od = 1;
The object is attachable as in BOSL2. BOSL2 is required.
*/
/*
polyID(d, n)
polyOD(d, n)
d diameter
n = number of sides
Calculate the inner(outer) diameter of a polygon from the outer(inner) where n is the number of sides.
The inner diameter is of the circle that passes through the center points of each side.
The outer diamter is of the circle that passes through each vertex.
*/
function polyID(d, n) = d * cos(180 / n);
function polyOD(d, n) = d / cos(180 / n);
function is_int(i) = floor(i) == i;
module polyCyl(n = 3, l = -1, h = -1, side = -1, id = -1, od = -1, tent = 0, anchor = CENTER, orient = UP, spin = 0) {
H = (h > 0) ? h : (l > 0) ? l : 1;
D = (side > 0) ? side / sin(180/n) : (id > 0) ? polyOD(id, n) : (od > 0) ? od : 1;
dummy0 = assert(is_int(n), "polyCyl - Number of sides must be an integer");
dummy1 = assert(n >= 3, "polyCyl - Number of sides must be >= 3");
attachable(anchor = anchor,
spin = spin,
orient = orient,
d = D,
h = H + tent*2)
{
hull()
union() {
if (tent > 0) up(H/2 + tent/2) #sphere(d = tent);
down(H/2)
linear_extrude(H)
circle(d = D, $fn = n);
if (tent > 0) down(H/2 + tent/2) sphere(d = tent);
}
children();
} // attachable
} // hexCyl
On Aug 22, 2023, at 20:39, Bryan Lee leebc11@acm.org wrote:
Can someone please help me with this math? My brain stopped braining.
I have a polygon with N sides, and a width of D, which is measured
flat-to-flat through the center.
I want to create an OpenSCAD cylinder() of the correct radius and a $FN of
N that is the same shape as the polygon.
Can anyone help me with this math?
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org