2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-10-01 22:20:43 +02:00
|
|
|
title: utils.linesIntersect()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2024-01-21 11:16:40 -08:00
|
|
|
The `utils.linesIntersect()` function finds the intersection between two line
|
2024-09-28 13:13:48 +02:00
|
|
|
segments. Returns a [Point](/reference/api/point/) object for the intersection, or `false`
|
2022-10-01 22:20:43 +02:00
|
|
|
if the lines don't intersect.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
Point | false utils.linesIntersect(
|
2024-09-28 13:13:48 +02:00
|
|
|
Point A,
|
|
|
|
Point B,
|
|
|
|
Point C,
|
2021-08-25 16:09:31 +02:00
|
|
|
Point D
|
|
|
|
)
|
|
|
|
```
|
|
|
|
|
2022-10-01 22:20:43 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-01 22:20:43 +02:00
|
|
|
<Example caption="A Utils.linesIntersect() example">
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2022-10-01 22:20:43 +02:00
|
|
|
({ Point, points, Path, paths, Snippet, snippets, utils, part }) => {
|
|
|
|
|
|
|
|
points.A = new Point(10, 10)
|
|
|
|
points.B = new Point(50, 40)
|
|
|
|
points.C = new Point(15, 30)
|
|
|
|
points.D = new Point(60, 15)
|
2024-09-28 13:13:48 +02:00
|
|
|
|
2022-10-01 22:20:43 +02:00
|
|
|
paths.AB = new Path().move(points.A).line(points.B)
|
|
|
|
paths.CD = new Path().move(points.C).line(points.D)
|
2024-09-28 13:13:48 +02:00
|
|
|
|
2022-10-01 22:20:43 +02:00
|
|
|
snippets.X = new Snippet(
|
|
|
|
"notch",
|
|
|
|
utils.linesIntersect(points.A, points.B, points.C, points.D)
|
|
|
|
)
|
|
|
|
|
|
|
|
return part
|
|
|
|
}
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
2022-10-01 22:20:43 +02:00
|
|
|
</Example>
|
|
|
|
|