mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-27 08:25:45 +02:00
rename
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# in_line
|
||||
# in_polyline2d
|
||||
|
||||
Checks wether a point is on a line.
|
||||
|
||||
@@ -12,7 +12,7 @@ Checks wether a point is on a line.
|
||||
|
||||
## Examples
|
||||
|
||||
include <in_line.scad>;
|
||||
include <in_polyline2d.scad>;
|
||||
|
||||
pts = [
|
||||
[0, 0],
|
||||
@@ -20,7 +20,7 @@ Checks wether a point is on a line.
|
||||
[10, 10]
|
||||
];
|
||||
|
||||
echo(in_line(pts, [-2, -3])); // false
|
||||
echo(in_line(pts, [5, 0])); // true
|
||||
echo(in_line(pts, [10, 5])); // true
|
||||
echo(in_line(pts, [10, 15])); // false
|
||||
echo(in_polyline2d(pts, [-2, -3])); // false
|
||||
echo(in_polyline2d(pts, [5, 0])); // true
|
||||
echo(in_polyline2d(pts, [10, 5])); // true
|
||||
echo(in_polyline2d(pts, [10, 15])); // false
|
@@ -1,4 +1,4 @@
|
||||
function __in_line(line_pts, pt, epsilon = 0.0001) =
|
||||
function __in_line2d(line_pts, pt, epsilon = 0.0001) =
|
||||
let(
|
||||
v1 = line_pts[0] - pt,
|
||||
v2 = line_pts[1] - pt
|
@@ -1,10 +0,0 @@
|
||||
include <__private__/__in_line.scad>;
|
||||
|
||||
function _in_line_sub(line_pts, pt, epsilon, iend, i = 0) =
|
||||
i == iend ? false : (
|
||||
__in_line([line_pts[i], line_pts[i + 1]], pt, epsilon) ? true :
|
||||
_in_line_sub(line_pts, pt, epsilon, iend, i + 1)
|
||||
);
|
||||
|
||||
function in_line(line_pts, pt, epsilon = 0.0001) = _in_line_sub(line_pts, pt, epsilon, len(line_pts) - 1);
|
||||
|
10
src/in_polyline2d.scad
Normal file
10
src/in_polyline2d.scad
Normal file
@@ -0,0 +1,10 @@
|
||||
include <__private__/__in_line2d.scad>;
|
||||
|
||||
function _in_polyline2d_sub(line_pts, pt, epsilon, iend, i = 0) =
|
||||
i == iend ? false : (
|
||||
__in_line2d([line_pts[i], line_pts[i + 1]], pt, epsilon) ? true :
|
||||
_in_polyline2d_sub(line_pts, pt, epsilon, iend, i + 1)
|
||||
);
|
||||
|
||||
function in_polyline2d(line_pts, pt, epsilon = 0.0001) = _in_polyline2d_sub(line_pts, pt, epsilon, len(line_pts) - 1);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
include <__private__/__lines_from.scad>;
|
||||
include <__private__/__in_line.scad>;
|
||||
include <__private__/__in_line2d.scad>;
|
||||
|
||||
function _in_shape_in_line_equation(edge, pt) =
|
||||
let(
|
||||
@@ -14,7 +14,7 @@ function _in_shape_in_line_equation(edge, pt) =
|
||||
|
||||
function _in_shape_in_any_edges_sub(edges, leng, pt, i, epsilon) =
|
||||
leng == i ? false : (
|
||||
__in_line(edges[i], pt, epsilon) ? true : _in_shape_in_any_edges_sub(edges, leng, pt, i + 1, epsilon)
|
||||
__in_line2d(edges[i], pt, epsilon) ? true : _in_shape_in_any_edges_sub(edges, leng, pt, i + 1, epsilon)
|
||||
);
|
||||
|
||||
function _in_shape_in_any_edges(edges, pt, epsilon) = _in_shape_in_any_edges_sub(edges, len(edges), pt, 0, epsilon);
|
||||
|
@@ -1,12 +1,12 @@
|
||||
include <__private__/__line_intersection.scad>;
|
||||
include <__private__/__in_line.scad>;
|
||||
include <__private__/__in_line2d.scad>;
|
||||
include <__private__/__lines_from.scad>;
|
||||
|
||||
function _trim_shape_any_intersection_sub(lines, line, lines_leng, i, epsilon) =
|
||||
let(
|
||||
p = __line_intersection(lines[i], line, epsilon)
|
||||
)
|
||||
(p != [] && __in_line(line, p, epsilon) && __in_line(lines[i], p, epsilon)) ? [i, p] : _trim_shape_any_intersection(lines, line, lines_leng, i + 1, epsilon);
|
||||
(p != [] && __in_line2d(line, p, epsilon) && __in_line2d(lines[i], p, epsilon)) ? [i, p] : _trim_shape_any_intersection(lines, line, lines_leng, i + 1, epsilon);
|
||||
|
||||
// return [idx, [x, y]] or []
|
||||
function _trim_shape_any_intersection(lines, line, lines_leng, i, epsilon) =
|
||||
|
Reference in New Issue
Block a user