mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-15 08:59:40 +00:00
Compare commits
4 commits
3a61714bc3
...
3e58a4c132
Author | SHA1 | Date | |
---|---|---|---|
|
3e58a4c132 | ||
|
50112abbe9 | ||
|
df720b99de | ||
|
ba73f4e1fd |
1 changed files with 9 additions and 9 deletions
|
@ -1929,7 +1929,7 @@ function _superformula(theta,m1,m2,n1,n2=1,n3=1,a=1,b=1) =
|
|||
// Usage: As Function
|
||||
// path = reuleaux_polygon(n, r|d=, ...);
|
||||
// Description:
|
||||
// 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 module, creates 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.
|
||||
// Arguments:
|
||||
// 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):
|
||||
// squircle(size=50, squareness=0.4);
|
||||
// squircle([80,60], 0.7, $fn=64);
|
||||
// Examples(2D): Ten increments of squareness parameter for a superellipse squircle
|
||||
// Example(2D): Ten increments of squareness parameter for a superellipse squircle
|
||||
// for(sq=[0:0.1:1])
|
||||
// stroke(squircle(100, sq, style="superellipse", $fn=128), closed=true, width=0.5);
|
||||
// Examples(2D): Standard vector anchors are based on the bounding box
|
||||
// Example(2D): Standard vector anchors are based on the bounding box
|
||||
// squircle(50, 0.6) show_anchors();
|
||||
// Examples(2D): Perimeter anchors, anchoring at bottom left and spinning 20°
|
||||
// Example(2D): Perimeter anchors, anchoring at bottom left and spinning 20°
|
||||
// squircle([60,40], 0.5, anchor=(BOTTOM+LEFT), atype="perim", spin=20)
|
||||
// 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"]));
|
||||
size = is_num(size) ? [size,size] : point2d(size);
|
||||
assert(all_positive(size), "All components of size must be positive.");
|
||||
path = squircle(size, squareness, style, atype, _module_call=true);
|
||||
path = squircle(size, squareness, style, atype="box");
|
||||
if (atype == "box") {
|
||||
attachable(anchor, spin, two_d=true, size=size, extent=false) {
|
||||
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, _module_call=false) =
|
||||
function squircle(size, squareness=0.5, style="fg", atype="box", anchor=CENTER, spin=0) =
|
||||
assert(squareness >= 0 && squareness <= 1)
|
||||
assert(is_num(size) || is_vector(size,2))
|
||||
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),
|
||||
path = style == "fg" ? _squircle_fg(size, squareness)
|
||||
: style == "superellipse" ? _squircle_se(size, squareness)
|
||||
: assert(false, "Style must be \"fg\" or \"superellipse\""),
|
||||
) reorient(anchor, spin, two_d=true, size=atype=="box"?size:undef, path=_module_call?undef:path, p=path, extent=true);
|
||||
: 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);
|
||||
|
||||
|
||||
/* 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
|
||||
x = cos(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)
|
||||
) [ra*x, rb*y] / r
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue