From 3c9e304675c05624469cd0dc92141adea7342c03 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Tue, 28 Jul 2020 17:54:45 -0400 Subject: [PATCH] fix find_noncollinear_points --- geometry.scad | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/geometry.scad b/geometry.scad index dd35ddc..168a91d 100644 --- a/geometry.scad +++ b/geometry.scad @@ -1359,21 +1359,40 @@ function first_noncollinear(i1, i2, points) = // find_noncollinear_points(points); // Description: // Finds the indices of three good non-collinear points from the points list `points`. -function find_noncollinear_points(points) = +function find_noncollinear_points(points,error=true,eps=EPSILON) = + let( + pa = points[0], + b = furthest_point(pa, points), + n = unit(points[b]-pa), + relpoints = [for(pt=points) pt-pa], + proj = relpoints * n, + distlist = [for(i=[0:len(points)-1]) norm(relpoints[i]-proj[i]*n)] + ) + max(distlist)