_in_shape_impl.scad
1 use <__comm__/__in_line.scad> 2 3 function _in_any_edges(edges, pt, epsilon) = 4 let( 5 leng = len(edges), 6 maybe_last = [for(i = 0; i < leng && !__in_line(edges[i], pt, epsilon); i = i + 1) i][leng - 1] 7 ) 8 is_undef(maybe_last); 9 10 function _does_pt_cross(pi, pj, pt) = 11 ((pi.y - pt.y) * (pj.y - pt.y) < 0) && (pt.x < lookup(pt.y, [[pi.y, pi.x], [pj.y, pj.x]])); 12 13 function _in_shape_sub(shapt_pts, leng, pt, cond, i = 0) = 14 let(j = i + 1) 15 j == leng ? cond : _in_shape_sub(shapt_pts, leng, pt, _does_pt_cross(shapt_pts[i], shapt_pts[j], pt) ? !cond : cond, j); 16