2020-12-30 17:00:14 +08:00
|
|
|
# lines_intersection
|
2020-05-18 17:32:52 +08:00
|
|
|
|
|
|
|
Find the intersection of two line segments. Return `[]` if lines don't intersect.
|
|
|
|
|
|
|
|
**Since:** 2.4
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2021-03-04 08:33:00 +08:00
|
|
|
- `line1` : Two points of 2D or 3D line1.
|
|
|
|
- `line2` : Two points of 2D or 3D line2.
|
2020-05-18 17:32:52 +08:00
|
|
|
- `ext` : Default to `false`, which doesn't extend a line to an intersection with another line.
|
|
|
|
- `epsilon` : An upper bound on the relative error due to rounding in floating point arithmetic. Default to 0.0001.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2020-05-19 14:45:06 +08:00
|
|
|
use <lines_intersection.scad>;
|
2020-05-18 17:32:52 +08:00
|
|
|
|
|
|
|
line1 = [[0, 0], [0, 10]];
|
|
|
|
line2 = [[5, 0], [-5, 5]];
|
|
|
|
line3 = [[5, 0], [2.5, 5]];
|
|
|
|
|
2020-05-19 14:45:06 +08:00
|
|
|
assert(lines_intersection(line1, line2) == [0, 2.5]);
|
|
|
|
assert(lines_intersection(line1, line3, ext = true) == [0, 10]);
|
2021-03-04 08:33:00 +08:00
|
|
|
|
|
|
|
line4 = [[0, 0, 0], [10, 10, 10]];
|
|
|
|
line5 = [[10, 0, 0], [0, 10, 10]];
|
|
|
|
assert(lines_intersection(line4, line5) == [5, 5, 5]);
|