mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Changes to noncollinear_triple
This commit is contained in:
parent
3bf22cd236
commit
b4e26c035c
3 changed files with 19 additions and 9 deletions
|
@ -92,7 +92,7 @@ function hull2d_path(points) =
|
|||
assert(is_path(points,2),"Invalid input to hull2d_path")
|
||||
len(points) < 2 ? []
|
||||
: len(points) == 2 ? [0,1]
|
||||
: let(tri=find_noncollinear_points(points, error=false))
|
||||
: let(tri=noncollinear_triple(points, error=false))
|
||||
tri == [] ? _hull_collinear(points)
|
||||
: let(
|
||||
remaining = [ for (i = [0:1:len(points)-1]) if (i != tri[0] && i!=tri[1] && i!=tri[2]) i ],
|
||||
|
@ -170,7 +170,7 @@ function hull3d_faces(points) =
|
|||
assert(is_path(points,3),"Invalid input to hull3d_faces")
|
||||
len(points) < 3 ? list_range(len(points))
|
||||
: let ( // start with a single non-collinear triangle
|
||||
tri = find_noncollinear_points(points, error=false)
|
||||
tri = noncollinear_triple(points, error=false)
|
||||
)
|
||||
tri==[] ? _hull_collinear(points)
|
||||
: let(
|
||||
|
@ -250,7 +250,7 @@ function _find_conflicts(point, planes) = [
|
|||
|
||||
|
||||
function _find_first_noncoplanar(plane, points, i) =
|
||||
(i >= len(points) || !coplanar(plane, points[i]))? i :
|
||||
(i >= len(points) || !points_on_plane([points[i]],plane))? i :
|
||||
_find_first_noncoplanar(plane, points, i+1);
|
||||
|
||||
|
||||
|
|
|
@ -675,7 +675,7 @@ module offset_sweep(
|
|||
r = offset_type=="round"? this_offset : undef,
|
||||
do_chamfer = offset_type == "chamfer"
|
||||
)
|
||||
assert(num_defined([r,delta])==1,"Must set `offset` to \"round\" or \"delta")
|
||||
assert(num_defined([r,delta])==1,str("Must set `offset` to ",round," or ",delta)
|
||||
let(
|
||||
vertices_faces = offset(
|
||||
path, r=r, delta=delta, chamfer = do_chamfer, closed=true,
|
||||
|
@ -1532,7 +1532,7 @@ function rounded_prism(bottom, top, joint_bot, joint_top, joint_sides, k_bot, k_
|
|||
// Determine which points are concave by making bottom 2d if necessary
|
||||
bot_proj = len(bottom[0])==2 ? bottom : project_plane(bottom, select(bottom,0,2)),
|
||||
bottom_sign = polygon_is_clockwise(bot_proj) ? 1 : -1,
|
||||
concave = [for(i=[0:N-1]) bottom_sign*sign(point_left_of_segment2d(select(bot_proj,i+1), select(bot_proj, i-1,i)))>0],
|
||||
concave = [for(i=[0:N-1]) bottom_sign*sign(point_left_of_line2d(select(bot_proj,i+1), select(bot_proj, i-1,i)))>0],
|
||||
top = is_undef(top) ? path3d(bottom,height/2) :
|
||||
len(top[0])==2 ? path3d(top,height/2) :
|
||||
top,
|
||||
|
@ -1547,11 +1547,11 @@ function rounded_prism(bottom, top, joint_bot, joint_top, joint_sides, k_bot, k_
|
|||
assert(jsvecok || jssingleok,
|
||||
str("Argument joint_sides is invalid. All entries must be nonnegative, and it must be a number, 2-vector, or a length ",N," list those."))
|
||||
assert(is_num(k_sides) || is_vector(k_sides,N), str("Curvature parameter k_sides must be a number or length ",N," vector"))
|
||||
assert(points_are_coplanar(bottom))
|
||||
assert(points_are_coplanar(top))
|
||||
assert(coplanar(bottom))
|
||||
assert(coplanar(top))
|
||||
assert(!is_num(k_sides) || (k_sides>=0 && k_sides<=1), "Curvature parameter k_sides must be in interval [0,1]")
|
||||
let(
|
||||
non_coplanar=[for(i=[0:N-1]) if (!points_are_coplanar(concat(select(top,i,i+1), select(bottom,i,i+1)))) [i,(i+1)%N]],
|
||||
non_coplanar=[for(i=[0:N-1]) if (!coplanar(concat(select(top,i,i+1), select(bottom,i,i+1)))) [i,(i+1)%N]],
|
||||
k_sides_vec = is_num(k_sides) ? repeat(k_sides, N) : k_sides,
|
||||
kbad = [for(i=[0:N-1]) if (k_sides_vec[i]<0 || k_sides_vec[i]>1) i],
|
||||
joint_sides_vec = jssingleok ? repeat(joint_sides,N) : joint_sides,
|
||||
|
|
12
vnf.scad
12
vnf.scad
|
@ -403,6 +403,16 @@ function _triangulate_planar_convex_polygons(polys) =
|
|||
outtris = concat(tris, newtris, newtris2)
|
||||
) outtris;
|
||||
|
||||
//**
|
||||
// this function may produce degenerate triangles:
|
||||
// _triangulate_planar_convex_polygons([ [for(i=[0:1]) [i,i],
|
||||
// [1,-1], [-1,-1],
|
||||
// for(i=[-1:0]) [i,i] ] ] )
|
||||
// == [[[-1, -1], [ 0, 0], [0, 0]]
|
||||
// [[-1, -1], [-1, -1], [0, 0]]
|
||||
// [[ 1, -1], [-1, -1], [0, 0]]
|
||||
// [[ 0, 0], [ 1, 1], [1, -1]] ]
|
||||
//
|
||||
|
||||
// Function: vnf_bend()
|
||||
// Usage:
|
||||
|
@ -647,7 +657,7 @@ function vnf_validate(vnf, show_warns=true, check_isects=false) =
|
|||
nonplanars = unique([
|
||||
for (face = faces) let(
|
||||
faceverts = [for (k=face) varr[k]]
|
||||
) if (!points_are_coplanar(faceverts)) [
|
||||
) if (!coplanar(faceverts)) [
|
||||
"ERROR",
|
||||
"NONPLANAR",
|
||||
"Face vertices are not coplanar",
|
||||
|
|
Loading…
Reference in a new issue