bug fixes

This commit is contained in:
Adrian Mariano 2022-11-01 23:36:52 -04:00
parent 3d6c3fca89
commit f035df980a
2 changed files with 7 additions and 10 deletions

View file

@ -336,20 +336,17 @@ function list_tail(list, from=1) =
// Topics: List Handling // Topics: List Handling
// See Also: list_bset() // See Also: list_bset()
// Description: // Description:
// Returns the items in `list` whose matching element in `index` is true. // Returns the items in `list` whose matching element in `index` evaluates as true.
// Arguments: // Arguments:
// list = Initial list to extract items from. // list = Initial list (or string) to extract items from.
// index = List of booleans. // index = List of values that will be evaluated as boolean, same length as `list`.
// Example: // Example:
// a = bselect([3,4,5,6,7], [false,true,true,false,true]); // Returns: [4,5,7] // a = bselect([3,4,5,6,7], [false,true,true,false,true]); // Returns: [4,5,7]
function bselect(list,index) = function bselect(list,index) =
assert(is_list(list)||is_string(list), "Improper list." ) assert(is_list(list)||is_string(list), "First argument must be a list or string." )
assert(is_list(index) && len(index)>=len(list) , "Improper index list." ) assert(is_list(index) && len(index)==len(list) , "Second argument must have same length as the first." )
is_string(list)? str_join(bselect( [for (x=list) x], index)) : is_string(list)? str_join(bselect( [for (x=list) x], index)) :
[for(i=[0:len(list)-1]) if (index[i]) list[i]]; [for(i=idx(list)) if (index[i]) list[i]];
// Section: List Construction // Section: List Construction

View file

@ -1049,7 +1049,7 @@ function vnf_halfspace(plane, vnf, closed=true) =
assert(_valid_plane(plane), "Invalid plane") assert(_valid_plane(plane), "Invalid plane")
assert(is_vnf(vnf), "Invalid vnf") assert(is_vnf(vnf), "Invalid vnf")
let( let(
inside = [for(x=vnf[0]) plane*[each x,-1] >= 0 ? 1 : 0], inside = [for(x=vnf[0]) plane*[each x,-1] >= -EPSILON ? 1 : 0],
vertexmap = [0,each cumsum(inside)], vertexmap = [0,each cumsum(inside)],
faces_edges_vertices = _vnfcut(plane, vnf[0],vertexmap,inside, vnf[1], last(vertexmap)), faces_edges_vertices = _vnfcut(plane, vnf[0],vertexmap,inside, vnf[1], last(vertexmap)),
newvert = concat(bselect(vnf[0],inside), faces_edges_vertices[2]) newvert = concat(bselect(vnf[0],inside), faces_edges_vertices[2])