mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-30 00:09:37 +00:00
Added points_are_collinear(). Renamed pointslist_is_coplanar() to points_are_coplanar()
This commit is contained in:
parent
c1e3f5d60a
commit
602e850d24
2 changed files with 19 additions and 4 deletions
|
@ -779,6 +779,21 @@ function polygon_line_intersection(poly, line, bounded=false, eps=EPSILON) =
|
||||||
res[0];
|
res[0];
|
||||||
|
|
||||||
|
|
||||||
|
// Function: points_are_collinear()
|
||||||
|
// Usage:
|
||||||
|
// points_are_collinear(points);
|
||||||
|
// Description:
|
||||||
|
// Given a list of points, returns true if all points in the list are collinear.
|
||||||
|
// Arguments:
|
||||||
|
// points = The list of points to test.
|
||||||
|
// eps = How much variance is allowed in testing that each point is on the same line. Default: `EPSILON` (1e-9)
|
||||||
|
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)]);
|
||||||
|
|
||||||
|
|
||||||
// Function: coplanar()
|
// Function: coplanar()
|
||||||
// Usage:
|
// Usage:
|
||||||
// coplanar(plane, point);
|
// coplanar(plane, point);
|
||||||
|
@ -794,15 +809,15 @@ function coplanar(plane, point, eps=EPSILON) =
|
||||||
abs(distance_from_plane(plane, point)) <= eps;
|
abs(distance_from_plane(plane, point)) <= eps;
|
||||||
|
|
||||||
|
|
||||||
// Function: pointslist_is_coplanar()
|
// Function: points_are_coplanar()
|
||||||
// Usage:
|
// Usage:
|
||||||
// pointslist_is_coplanar(points);
|
// points_are_coplanar(points);
|
||||||
// Description:
|
// Description:
|
||||||
// Given a list of points, returns true if all points in the list are coplanar.
|
// Given a list of points, returns true if all points in the list are coplanar.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// points = The list of points to test.
|
// points = The list of points to test.
|
||||||
// eps = How much variance is allowed in testing that each point is on the same plane. Default: `EPSILON` (1e-9)
|
// eps = How much variance is allowed in testing that each point is on the same plane. Default: `EPSILON` (1e-9)
|
||||||
function pointslist_is_coplanar(points, eps=EPSILON) =
|
function points_are_coplanar(points, eps=EPSILON) =
|
||||||
let(
|
let(
|
||||||
plane = plane_from_pointslist(points, fast=true, eps=eps)
|
plane = plane_from_pointslist(points, fast=true, eps=eps)
|
||||||
) all([for (pt = points) coplanar(plane, pt, eps=eps)]);
|
) all([for (pt = points) coplanar(plane, pt, eps=eps)]);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,185];
|
BOSL_VERSION = [2,0,186];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue