mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-09-01 00:02:05 +02:00
Bugfix and optimization for find_noncollinear_points(). Optimized points_are_collinear()
This commit is contained in:
@@ -818,8 +818,10 @@ function polygon_line_intersection(poly, line, bounded=false, eps=EPSILON) =
|
||||
function points_are_collinear(points, eps=EPSILON) =
|
||||
let(
|
||||
a = furthest_point(points[0], points),
|
||||
b = furthest_point(points[a], points)
|
||||
) all([for (pt = points) collinear(points[a], points[b], pt, eps=eps)]);
|
||||
b = furthest_point(points[a], points),
|
||||
pa = points[a],
|
||||
pb = points[b]
|
||||
) all([for (pt = points) collinear(pa, pb, pt, eps=eps)]);
|
||||
|
||||
|
||||
// Function: coplanar()
|
||||
@@ -1028,12 +1030,17 @@ function find_noncollinear_points(points) =
|
||||
let(
|
||||
a = 0,
|
||||
b = furthest_point(points[a], points),
|
||||
pa = points[a],
|
||||
pb = points[b],
|
||||
c = max_index([
|
||||
for (p=points)
|
||||
(approx(p,pa) || approx(p,pb))? 0 :
|
||||
sin(vector_angle(points[a]-p,points[b]-p)) *
|
||||
norm(p-points[a]) * norm(p-points[b])
|
||||
])
|
||||
) [a, b, c];
|
||||
)
|
||||
assert(c!=a && c!=b, "Cannot find three noncollinear points in pointlist.")
|
||||
[a, b, c];
|
||||
|
||||
|
||||
// Function: pointlist_bounds()
|
||||
|
Reference in New Issue
Block a user