// recrangularSignetRingGenerator.scad // Adam Zeloof // 2.15.2022 include module ringtop(w, h, t, r) { // based on an answer found at https://math.stackexchange.com/questions/543496 P = [w/2,h]; d = sqrt(P[0]^2+P[1]^2); rho = r/d; ad = rho^2; bd = rho*sqrt(1-ad); T = [ad*P[0] + bd*P[1], ad*P[1] - bd*P[0]]; linear_extrude(t) polygon([[0,0], T, P, [-P[0],P[1]], [-T[0],T[1]]]); } module rectangularSignetRing(size, wall, t, w, h, res) { id = us_size(size); difference() { difference() { union() { cylinder(h=t, r=id/2+wall, $fn=res); ringtop(w, h, t, id/2+wall); } translate([-w/2, h, 0]) cube([w, w, t]); } cylinder(h=t, r=id/2, $fn=res); } }