Skip to content

Commit

Permalink
Merge pull request #1527 from adrianVmariano/master
Browse files Browse the repository at this point in the history
doc fixes
  • Loading branch information
adrianVmariano authored Dec 22, 2024
2 parents a95916b + cb0e5c1 commit a25f706
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 83 deletions.
5 changes: 2 additions & 3 deletions gears.scad
Original file line number Diff line number Diff line change
Expand Up @@ -3353,8 +3353,7 @@ function _gear_tooth_profile(
xy = _involute(brad,i),
pol = xy_to_polar(xy)
)
if (pol.x <= arad * 1.1)
[pol.x, 90-pol.y]
if (pol.x <= arad * 1.1) [pol.x, 90-pol.y]
],

// Generate reverse lookup table for involute radii, by angle
Expand Down Expand Up @@ -3442,7 +3441,7 @@ function _gear_tooth_profile(
if (!internal && round_r<=0) isect_pt,
each tooth_half_raw,
if (internal && round_r>0) each arc(n=8, r=round_r, corner=rcorner),
if (internal && round_r<=0) isect,
if (internal && round_r<=0) isect_pt,
]),

// Strip "jaggies" if found.
Expand Down
168 changes: 88 additions & 80 deletions shapes2d.scad
Original file line number Diff line number Diff line change
Expand Up @@ -1568,10 +1568,6 @@ module egg(length,r1,r2,R,d1,d2,D,anchor=CENTER, spin=0)
// ring(r1=5,r2=7, angle=[0,360], n=32); // full circle
// ring(r=5, points=[[0,0],[3,3],[5,2]], full=false, n=32);
// ring(32,-2, cp=[1,1], points=[[4,4],[-3,6]], full=false);
// ring(r=5,ring_width=-1, n=32);
// ring(points=[[0,0],[3,3],[5,2]], ring_width=2, n=32);
// ring(points=[[0,0],[3,3],[5,2]], r=1, n=32);
// ring(cp=[3,3], points=[[4,4],[1,3]], ring_width=1);
// Example(2D): Using corner, the outer radius is the one tangent to the corner
// corner = [[0,0],[4,4],[7,3]];
// ring(corner=corner, r2=3, r1=2,n=22);
Expand Down Expand Up @@ -1752,22 +1748,30 @@ module glued_circles(r, spread=10, tangent=30, d, anchor=CENTER, spin=0) {


// Function&Module: squircle()
// Synopsis: Creates a shape between a circle and a square, centered on the origin.
// Synopsis: Creates a shape between a circle and a square.
// SynTags: Geom, Path
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), square(), supershape()
// See Also: circle(), square(), rect(), ellipse(), supershape()
// Usage: As Module
// squircle(size, [squareness], [style]) [ATTACHMENTS];
// squircle(size, [squareness], [style=]) [ATTACHMENTS];
// Usage: As Function
// path = squircle(size, [squareness], [style]);
// path = squircle(size, [squareness], [style=]);
// Description:
// A [squircle](https://en.wikipedia.org/wiki/Squircle) is a shape intermediate between a square/rectangle and a circle/ellipse. Squircles are sometimes used to make dinner plates (more area for the same radius as a circle), keyboard buttons, and smartphone icons. Old CRT television screens also resembled elongated squircles.
// A [squircle](https://en.wikipedia.org/wiki/Squircle) is a shape intermediate between a square/rectangle and a circle/ellipse.
// Squircles are sometimes used to make dinner plates (more area for the same radius as a circle), keyboard buttons, and smartphone
// icons. Old CRT television screens also resembled elongated squircles.
// .
// Multiple definitions exist for the squircle. We support two versions: the superellipse {{supershape()}} Example 3, also known as the Lamé upper squircle), and the Fernandez-Guasti squircle. They are visually almost indistinguishable, with the superellipse having slightly rounder "corners" than FG at the same corner radius. These two squircles have different, unintuitive methods for controlling how square or circular the shape is. A `squareness` parameter determines the shape, specifying the corner position linearly, with 0 being on the circle and 1 being the square. Vertices are positioned to be more dense near the corners to preserve smoothness at low values of `$fn`'.
// Multiple definitions exist for the squircle. We support two versions: the Fernandez-Guasti squircle and the superellipse
// ({{supershape()}} Example 3, also known as the Lamé upper squircle), and the . They are visually almost indistinguishable,
// with the superellipse having slightly rounder "corners" than FG at the same corner radius. These two squircles have different,
// unintuitive methods for controlling how square or circular the shape is. The `squareness` parameter determines the shape, specifying
// the corner position linearly, with 0 giving the circle and 1 giving the square. Vertices are positioned to be more dense near the
// corners to preserve smoothness at low values of `$fn`.
// .
// For the "superellipse" style, the special case where the superellipse exponent is 4 results in a squircle at the geometric mean between radial points on the circle and square, corresponding to squareness=0.456786.
// For the "superellipse" style, the special case where the superellipse exponent is 4 results in a squircle at the geometric mean
// between radial points on the circle and square, corresponding to squareness=0.456786.
// .
// When called as a module, creates a 2D squircle with the desired squareness.
// When called as a module, creates a 2D squircle with the specified squareness.
// When called as a function, returns a 2D path for a squircle.
// Arguments:
// size = Same as the `size` parameter in `square()`, can be a single number or a vector `[xsize,ysize]`.
Expand Down Expand Up @@ -1963,6 +1967,78 @@ module keyhole(l, r1, r2, shoulder_r=0, d1, d2, length, anchor=CTR, spin=0) {
}



// Function&Module: reuleaux_polygon()
// Synopsis: Creates a constant-width shape that is not circular.
// SynTags: Geom, Path
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: regular_ngon(), pentagon(), hexagon(), octagon()
// Usage: As Module
// reuleaux_polygon(n, r|d=, ...) [ATTACHMENTS];
// Usage: As Function
// path = reuleaux_polygon(n, r|d=, ...);
// 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 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
// r = Radius of the shape. Scale shape to fit in a circle of radius r.
// ---
// d = Diameter of the shape. Scale shape to fit in a circle of diameter d.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// Named Anchors:
// "tip0", "tip1", etc. = Each tip has an anchor, pointing outwards.
// Examples(2D):
// reuleaux_polygon(n=3, r=50);
// reuleaux_polygon(n=5, d=100);
// Examples(2D): Standard vector anchors are based on extents
// reuleaux_polygon(n=3, d=50) show_anchors(custom=false);
// Examples(2D): Named anchors exist for the tips
// reuleaux_polygon(n=3, d=50) show_anchors(std=false);
module reuleaux_polygon(n=3, r, d, anchor=CENTER, spin=0) {
check = assert(n>=3 && (n%2)==1);
r = get_radius(r=r, d=d, dflt=1);
path = reuleaux_polygon(n=n, r=r);
anchors = [
for (i = [0:1:n-1]) let(
ca = 360 - i * 360/n,
cp = polar_to_xy(r, ca)
) named_anchor(str("tip",i), cp, unit(cp,BACK), 0),
];
attachable(anchor,spin, two_d=true, path=path, extent=false, anchors=anchors) {
polygon(path);
children();
}
}


function reuleaux_polygon(n=3, r, d, anchor=CENTER, spin=0) =
assert(n>=3 && (n%2)==1)
let(
r = get_radius(r=r, d=d, dflt=1),
ssegs = max(3,ceil(segs(r)/n)),
slen = norm(polar_to_xy(r,0)-polar_to_xy(r,180-180/n)),
path = [
for (i = [0:1:n-1]) let(
ca = 180 - (i+0.5) * 360/n,
sa = ca + 180 + (90/n),
ea = ca + 180 - (90/n),
cp = polar_to_xy(r, ca)
) each arc(n=ssegs-1, r=slen, cp=cp, angle=[sa,ea], endpoint=false)
],
anchors = [
for (i = [0:1:n-1]) let(
ca = 360 - i * 360/n,
cp = polar_to_xy(r, ca)
) named_anchor(str("tip",i), cp, unit(cp,BACK), 0),
]
) reorient(anchor,spin, two_d=true, path=path, extent=false, anchors=anchors, p=path);





// Function&Module: supershape()
// Synopsis: Creates a 2D [Superformula](https://en.wikipedia.org/wiki/Superformula) shape.
// SynTags: Geom, Path
Expand Down Expand Up @@ -2049,74 +2125,6 @@ function _superformula(theta,m1,m2,n1,n2=1,n3=1,a=1,b=1) =
pow(pow(abs(cos(m1*theta/4)/a),n2)+pow(abs(sin(m2*theta/4)/b),n3),-1/n1);


// Function&Module: reuleaux_polygon()
// Synopsis: Creates a constant-width shape that is not circular.
// SynTags: Geom, Path
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: regular_ngon(), pentagon(), hexagon(), octagon()
// Usage: As Module
// reuleaux_polygon(n, r|d=, ...) [ATTACHMENTS];
// Usage: As Function
// path = reuleaux_polygon(n, r|d=, ...);
// 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 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
// r = Radius of the shape. Scale shape to fit in a circle of radius r.
// ---
// d = Diameter of the shape. Scale shape to fit in a circle of diameter d.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// Named Anchors:
// "tip0", "tip1", etc. = Each tip has an anchor, pointing outwards.
// Examples(2D):
// reuleaux_polygon(n=3, r=50);
// reuleaux_polygon(n=5, d=100);
// Examples(2D): Standard vector anchors are based on extents
// reuleaux_polygon(n=3, d=50) show_anchors(custom=false);
// Examples(2D): Named anchors exist for the tips
// reuleaux_polygon(n=3, d=50) show_anchors(std=false);
module reuleaux_polygon(n=3, r, d, anchor=CENTER, spin=0) {
check = assert(n>=3 && (n%2)==1);
r = get_radius(r=r, d=d, dflt=1);
path = reuleaux_polygon(n=n, r=r);
anchors = [
for (i = [0:1:n-1]) let(
ca = 360 - i * 360/n,
cp = polar_to_xy(r, ca)
) named_anchor(str("tip",i), cp, unit(cp,BACK), 0),
];
attachable(anchor,spin, two_d=true, path=path, extent=false, anchors=anchors) {
polygon(path);
children();
}
}


function reuleaux_polygon(n=3, r, d, anchor=CENTER, spin=0) =
assert(n>=3 && (n%2)==1)
let(
r = get_radius(r=r, d=d, dflt=1),
ssegs = max(3,ceil(segs(r)/n)),
slen = norm(polar_to_xy(r,0)-polar_to_xy(r,180-180/n)),
path = [
for (i = [0:1:n-1]) let(
ca = 180 - (i+0.5) * 360/n,
sa = ca + 180 + (90/n),
ea = ca + 180 - (90/n),
cp = polar_to_xy(r, ca)
) each arc(n=ssegs-1, r=slen, cp=cp, angle=[sa,ea], endpoint=false)
],
anchors = [
for (i = [0:1:n-1]) let(
ca = 360 - i * 360/n,
cp = polar_to_xy(r, ca)
) named_anchor(str("tip",i), cp, unit(cp,BACK), 0),
]
) reorient(anchor,spin, two_d=true, path=path, extent=false, anchors=anchors, p=path);



// Section: Text

Expand Down

0 comments on commit a25f706

Please sign in to comment.