mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Re-organized region.scad docs.
This commit is contained in:
parent
ef0c92cfa5
commit
855aa0cf36
2 changed files with 37 additions and 37 deletions
72
regions.scad
72
regions.scad
|
@ -152,6 +152,42 @@ function region_path_crossings(path, region, closed=true, eps=EPSILON) = sort([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
// Function: split_path_at_region_crossings()
|
||||||
|
// Usage:
|
||||||
|
// polylines = split_path_at_region_crossings(path, region, [eps]);
|
||||||
|
// Description:
|
||||||
|
// Splits a path into polyline sections wherever the path crosses the perimeter of a region.
|
||||||
|
// Splits may occur mid-segment, so new vertices will be created at the intersection points.
|
||||||
|
// Arguments:
|
||||||
|
// path = The path to split up.
|
||||||
|
// region = The region to check for perimeter crossings of.
|
||||||
|
// closed = If true, treat path as a closed polygon. Default: true
|
||||||
|
// eps = Acceptable variance. Default: `EPSILON` (1e-9)
|
||||||
|
// Example(2D):
|
||||||
|
// path = square(50,center=false);
|
||||||
|
// region = [circle(d=80), circle(d=40)];
|
||||||
|
// polylines = split_path_at_region_crossings(path, region);
|
||||||
|
// color("#aaa") region(region);
|
||||||
|
// rainbow(polylines) stroke($item, closed=false, width=2);
|
||||||
|
function split_path_at_region_crossings(path, region, closed=true, eps=EPSILON) =
|
||||||
|
let(
|
||||||
|
path = deduplicate(path, eps=eps),
|
||||||
|
region = [for (path=region) deduplicate(path, eps=eps)],
|
||||||
|
xings = region_path_crossings(path, region, closed=closed, eps=eps),
|
||||||
|
crossings = deduplicate(
|
||||||
|
concat([[0,0]], xings, [[len(path)-1,1]]),
|
||||||
|
eps=eps
|
||||||
|
),
|
||||||
|
subpaths = [
|
||||||
|
for (p = pair(crossings))
|
||||||
|
deduplicate(eps=eps,
|
||||||
|
path_subselect(path, p[0][0], p[0][1], p[1][0], p[1][1], closed=closed)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
subpaths;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Section: Offsets and Boolean 2D Geometry
|
// Section: Offsets and Boolean 2D Geometry
|
||||||
|
|
||||||
|
@ -512,42 +548,6 @@ function offset(
|
||||||
) return_faces? [edges,faces] : edges;
|
) return_faces? [edges,faces] : edges;
|
||||||
|
|
||||||
|
|
||||||
// Function: split_path_at_region_crossings()
|
|
||||||
// Usage:
|
|
||||||
// polylines = split_path_at_region_crossings(path, region, [eps]);
|
|
||||||
// Description:
|
|
||||||
// Splits a path into polyline sections wherever the path crosses the perimeter of a region.
|
|
||||||
// Splits may occur mid-segment, so new vertices will be created at the intersection points.
|
|
||||||
// Arguments:
|
|
||||||
// path = The path to split up.
|
|
||||||
// region = The region to check for perimeter crossings of.
|
|
||||||
// closed = If true, treat path as a closed polygon. Default: true
|
|
||||||
// eps = Acceptable variance. Default: `EPSILON` (1e-9)
|
|
||||||
// Example(2D):
|
|
||||||
// path = square(50,center=false);
|
|
||||||
// region = [circle(d=80), circle(d=40)];
|
|
||||||
// polylines = split_path_at_region_crossings(path, region);
|
|
||||||
// color("#aaa") region(region);
|
|
||||||
// rainbow(polylines) stroke($item, closed=false, width=2);
|
|
||||||
function split_path_at_region_crossings(path, region, closed=true, eps=EPSILON) =
|
|
||||||
let(
|
|
||||||
path = deduplicate(path, eps=eps),
|
|
||||||
region = [for (path=region) deduplicate(path, eps=eps)],
|
|
||||||
xings = region_path_crossings(path, region, closed=closed, eps=eps),
|
|
||||||
crossings = deduplicate(
|
|
||||||
concat([[0,0]], xings, [[len(path)-1,1]]),
|
|
||||||
eps=eps
|
|
||||||
),
|
|
||||||
subpaths = [
|
|
||||||
for (p = pair(crossings))
|
|
||||||
deduplicate(eps=eps,
|
|
||||||
path_subselect(path, p[0][0], p[0][1], p[1][0], p[1][1], closed=closed)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
subpaths;
|
|
||||||
|
|
||||||
|
|
||||||
function _tag_subpaths(path, region, eps=EPSILON) =
|
function _tag_subpaths(path, region, eps=EPSILON) =
|
||||||
let(
|
let(
|
||||||
subpaths = split_path_at_region_crossings(path, region, eps=eps),
|
subpaths = split_path_at_region_crossings(path, region, eps=eps),
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,111];
|
BOSL_VERSION = [2,0,112];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue