Compare commits

..

No commits in common. "50112abbe9239009d890d47a84e70f9cd13e312d" and "cba3391131358c114d80001fdf0bbeef96222298" have entirely different histories.

View file

@ -1929,7 +1929,7 @@ function _superformula(theta,m1,m2,n1,n2=1,n3=1,a=1,b=1) =
// Usage: As Function // Usage: As Function
// path = reuleaux_polygon(n, r|d=, ...); // path = reuleaux_polygon(n, r|d=, ...);
// Description: // Description:
// When called as a module, creates a 2D Reuleaux Polygon; a constant width shape that is not circular. Uses "intersect" type anchoring. // When called as a module, reates a 2D Reuleaux Polygon; a constant width shape that is not circular. Uses "intersect" type anchoring.
// When called as a function, returns a 2D path for a Reulaux Polygon. // When called as a function, returns a 2D path for a Reulaux Polygon.
// Arguments: // Arguments:
// n = Number of "sides" to the Reuleaux Polygon. Must be an odd positive number. Default: 3 // n = Number of "sides" to the Reuleaux Polygon. Must be an odd positive number. Default: 3
@ -2015,12 +2015,12 @@ function reuleaux_polygon(n=3, r, d, anchor=CENTER, spin=0) =
// Examples(2D): // Examples(2D):
// squircle(size=50, squareness=0.4); // squircle(size=50, squareness=0.4);
// squircle([80,60], 0.7, $fn=64); // squircle([80,60], 0.7, $fn=64);
// Example(2D): Ten increments of squareness parameter for a superellipse squircle // Examples(2D): Ten increments of squareness parameter for a superellipse squircle
// for(sq=[0:0.1:1]) // for(sq=[0:0.1:1])
// stroke(squircle(100, sq, style="superellipse", $fn=128), closed=true, width=0.5); // stroke(squircle(100, sq, style="superellipse", $fn=128), closed=true, width=0.5);
// Example(2D): Standard vector anchors are based on the bounding box // Examples(2D): Standard vector anchors are based on the bounding box
// squircle(50, 0.6) show_anchors(); // squircle(50, 0.6) show_anchors();
// Example(2D): Perimeter anchors, anchoring at bottom left and spinning 20° // Examples(2D): Perimeter anchors, anchoring at bottom left and spinning 20°
// squircle([60,40], 0.5, anchor=(BOTTOM+LEFT), atype="perim", spin=20) // squircle([60,40], 0.5, anchor=(BOTTOM+LEFT), atype="perim", spin=20)
// show_anchors(); // show_anchors();
@ -2029,7 +2029,7 @@ module squircle(size, squareness=0.5, style="fg", atype="box", anchor=CENTER, sp
anchorchk = assert(in_list(atype, ["box", "perim"])); anchorchk = assert(in_list(atype, ["box", "perim"]));
size = is_num(size) ? [size,size] : point2d(size); size = is_num(size) ? [size,size] : point2d(size);
assert(all_positive(size), "All components of size must be positive."); assert(all_positive(size), "All components of size must be positive.");
path = squircle(size, squareness, style, atype="box"); path = squircle(size, squareness, style, atype, _module_call=true);
if (atype == "box") { if (atype == "box") {
attachable(anchor, spin, two_d=true, size=size, extent=false) { attachable(anchor, spin, two_d=true, size=size, extent=false) {
polygon(path); polygon(path);
@ -2044,7 +2044,7 @@ module squircle(size, squareness=0.5, style="fg", atype="box", anchor=CENTER, sp
} }
function squircle(size, squareness=0.5, style="fg", atype="box", anchor=CENTER, spin=0) = function squircle(size, squareness=0.5, style="fg", atype="box", anchor=CENTER, spin=0, _module_call=false) =
assert(squareness >= 0 && squareness <= 1) assert(squareness >= 0 && squareness <= 1)
assert(is_num(size) || is_vector(size,2)) assert(is_num(size) || is_vector(size,2))
assert(in_list(atype, ["box", "perim"])) assert(in_list(atype, ["box", "perim"]))
@ -2052,8 +2052,8 @@ function squircle(size, squareness=0.5, style="fg", atype="box", anchor=CENTER,
size = is_num(size) ? [size,size] : point2d(size), size = is_num(size) ? [size,size] : point2d(size),
path = style == "fg" ? _squircle_fg(size, squareness) path = style == "fg" ? _squircle_fg(size, squareness)
: style == "superellipse" ? _squircle_se(size, squareness) : style == "superellipse" ? _squircle_se(size, squareness)
: assert(false, "Style must be \"fg\" or \"superellipse\"") : assert(false, "Style must be \"fg\" or \"superellipse\""),
) reorient(anchor, spin, two_d=true, size=atype=="box"?size:undef, path=atype=="box"?undef:path, p=path, extent=true); ) reorient(anchor, spin, two_d=true, size=atype=="box"?size:undef, path=_module_call?undef:path, p=path, extent=true);
/* FG squircle functions */ /* FG squircle functions */
@ -2096,7 +2096,7 @@ function _squircle_se(size, squareness) = [
theta = a + fgsq*sin(4*a)*30/PI, // tighter angle steps at corners theta = a + fgsq*sin(4*a)*30/PI, // tighter angle steps at corners
x = cos(theta), x = cos(theta),
y = sin(theta), y = sin(theta),
r = (abs(x)^n + abs(y)^n)^(1/n) // superellipse r = (abs(x)^n + abs(y)^n)^(1/n), // superellipse
//r = _superformula(theta=theta, m1=4,m2=4,n1=n,n2=n,n3=n,a=1,b=1) //r = _superformula(theta=theta, m1=4,m2=4,n1=n,n2=n,n3=n,a=1,b=1)
) [ra*x, rb*y] / r ) [ra*x, rb*y] / r
]; ];