mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 00:09:41 +00:00
Doc update of polygon_triangulate
This commit is contained in:
parent
e60f5fd932
commit
abab41a2db
2 changed files with 3 additions and 30 deletions
|
@ -1698,7 +1698,7 @@ function point_in_polygon(point, poly, nonzero=false, eps=EPSILON) =
|
|||
|
||||
// Function: polygon_triangulate()
|
||||
// Usage:
|
||||
// triangles = polygon_triangulate(poly, [ind], [eps])
|
||||
// triangles = polygon_triangulate(poly, [ind], [error], [eps])
|
||||
// Description:
|
||||
// Given a simple polygon in 2D or 3D, triangulates it and returns a list
|
||||
// of triples indexing into the polygon vertices. When the optional argument `ind` is
|
||||
|
@ -1728,6 +1728,7 @@ function point_in_polygon(point, poly, nonzero=false, eps=EPSILON) =
|
|||
// Arguments:
|
||||
// poly = Array of the polygon vertices.
|
||||
// ind = A list indexing the vertices of the polygon in `poly`.
|
||||
// error = If false, returns `undef` when the polygon cannot be triangulated; otherwise, issues an assert error. Default: true.
|
||||
// eps = A maximum tolerance in geometrical tests. Default: EPSILON
|
||||
// Example(2D,NoAxes): a simple polygon; see from above
|
||||
// poly = star(id=10, od=15,n=11);
|
||||
|
@ -1767,7 +1768,7 @@ function point_in_polygon(point, poly, nonzero=false, eps=EPSILON) =
|
|||
// vnf_wireframe(vnf_tri, width=.15);
|
||||
function polygon_triangulate(poly, ind, error=true, eps=EPSILON) =
|
||||
assert(is_path(poly) && len(poly)>=3, "Polygon `poly` should be a list of at least three 2d or 3d points")
|
||||
assert(is_undef(ind) || (is_vector(ind) && min(ind)>=0 && max(ind)<len(poly) ),
|
||||
assert(is_undef(ind) || (is_vector(ind) && min(ind)>=0 && max(ind)<len(poly) ),
|
||||
"Improper or out of bounds list of indices")
|
||||
let( ind = is_undef(ind) ? count(len(poly)) : ind )
|
||||
len(ind) <=2 ? [] :
|
||||
|
|
28
vnf.scad
28
vnf.scad
|
@ -384,34 +384,6 @@ function _join_paths_at_vertices(path1,path2,v1,v2) =
|
|||
];
|
||||
|
||||
|
||||
// Given a region that is connected and has its outer border in region[0],
|
||||
// produces a polygon with the same points that has overlapping connected paths
|
||||
// to join internal holes to the outer border. Output is a single path.
|
||||
function _old_cleave_connected_region(region) =
|
||||
len(region)==0? [] :
|
||||
len(region)<=1? clockwise_polygon(region[0]) :
|
||||
let(
|
||||
dists = [
|
||||
for (i=[1:1:len(region)-1])
|
||||
_path_path_closest_vertices(region[0],region[i])
|
||||
],
|
||||
idxi = min_index(column(dists,0)),
|
||||
newoline = _join_paths_at_vertices(
|
||||
region[0], region[idxi+1],
|
||||
dists[idxi][1], dists[idxi][2]
|
||||
)
|
||||
) len(region)==2? clockwise_polygon(newoline) :
|
||||
let(
|
||||
orgn = [
|
||||
newoline,
|
||||
for (i=idx(region))
|
||||
if (i>0 && i!=idxi+1)
|
||||
region[i]
|
||||
]
|
||||
)
|
||||
assert(len(orgn)<len(region))
|
||||
_old_cleave_connected_region(orgn);
|
||||
|
||||
/// Internal Function: _cleave_connected_region(region, eps)
|
||||
/// Description:
|
||||
/// Given a region that is connected and has its outer border in region[0],
|
||||
|
|
Loading…
Reference in a new issue