Skip to content

Commit b044ad9

Browse files
add fill() and hinge doc tweaks
1 parent 041cb4d commit b044ad9

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

hinges.scad

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ include <screws.scad>
9898
// right(.5)fwd(-3)color("blue")text("round_bot=1.5",size=1);
9999
// Arguments:
100100
// length = total length of the entire hinge
101-
// offset = horizontal offset of the hinge pin center from the mount point
102101
// segs = number of hinge segments
102+
// offset = horizontal offset of the hinge pin center from the mount point
103103
// inner = set to true for the "inner" hinge. Default: false
104104
// ---
105105
// arm_height = vertical height of the arm that holds the hinge barrel. Default: 0
@@ -216,6 +216,22 @@ include <screws.scad>
216216
// cuboid([4,40,15])
217217
// position(TOP+RIGHT) orient(anchor=RIGHT)
218218
// knuckle_hinge(length=35, segs=5, offset=2, inner=true, knuckle_clearance=1);
219+
// Example(3D,NoScales,VPR=[57.80,0.00,308.00],VPD=54.24,VPT=[2.34,0.76,0.15]): If you want the hinge leaves to fold flat together, pick a hinge configuration that places the centerline of the hinge pin on the plane of the hinge leaf. Hinges that fold entirely flat probably won't work, so we add some clearance between the leaves.
220+
// $fn=32;
221+
// thickness=2;
222+
// clearance=.2;
223+
// yflip_copy()
224+
// color(["green","red"][$idx])
225+
// diff()
226+
// fwd(clearance/2)
227+
// cuboid([20,thickness,7],anchor=BACK)
228+
// back(clearance/2)
229+
// down(thickness/3)
230+
// position(TOP+BACK)
231+
// knuckle_hinge(20, segs=5, offset=thickness+clearance,
232+
// inner=$orig, knuckle_clearance=clearance,
233+
// knuckle_diam=2*thickness+clearance,
234+
// arm_angle=90, arm_height=0, clear_top=true);
219235

220236
function knuckle_hinge(length, segs, offset, inner=false, arm_height=0, arm_angle=45, gap=0.2,
221237
seg_ratio=1, knuckle_diam=4, pin_diam=1.75, fill=true, clear_top=false,

regions.scad

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,4 +1523,48 @@ module hull_region(region)
15231523
}
15241524

15251525

1526+
// Function: fill()
1527+
// Synopsis: Remove holes from a {{region}}
1528+
// SynTags: Geom, Path
1529+
// Topics: Regions, Polygons, Shapes2D
1530+
// Usage:
1531+
// filled = fill(region);
1532+
// Description:
1533+
// Given a {{region}}, fill in any internal holes in the components of the region. This returns the outside border of each region component, and
1534+
// is equivalent to {{hull()}} for region components whose outside boundary is convex.
1535+
// Arguments:
1536+
// region = region to fill
1537+
// Example(2D, NoAxes): The original region in green has internal holes and subparts that are all filled in on the yellow filled region.
1538+
// $fs=.5;$fa=1;
1539+
// reg=[circle(r=10),right(5.5,circle(r=1)),
1540+
// circle(r=8), circle(r=3),
1541+
// right(5.5,rect([3,4]))];
1542+
// color("green")region(reg);
1543+
// right(25)region(fill(reg));
1544+
// Example(2D, NoAxes): Here the input region in green has two components:
1545+
// reg = [circle(8), circle(6)];
1546+
// reg2 = union([reg, fwd(18,reg)]);
1547+
// color("green")region(reg2);
1548+
// right(18) region(fill(reg2));
1549+
1550+
function fill(region) =
1551+
let(
1552+
region = force_region(region)
1553+
)
1554+
assert(is_region(region), "\nInput is not a region.")
1555+
let(
1556+
inside = [for(i=idx(region))
1557+
let(pt = mean([region[i][0], region[i][1]]))
1558+
[for(j=idx(region)) i==j ? 0
1559+
: point_in_polygon(pt,region[j]) >=0 ? 1 : 0]
1560+
],
1561+
level = inside*repeat(1,len(region))
1562+
)
1563+
[ for(i=idx(region))
1564+
if(level[i]==0) clockwise_polygon(region[i])];
1565+
1566+
1567+
1568+
1569+
15261570
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

0 commit comments

Comments
 (0)