1
0
Fork 0
freesewing/sites/dev/docs/reference/api/utils/beamsintersect/readme.mdx
Jonathan Haas 4b83212f41 Fix and improve path intersection methods
- Add path.intersectsBeam() method
- Add utils.beamIntersectsLine() method
- Simplify calculation and improve precision on beam intersections
- Document return types properly
- beamIntersectsCurve now uses the proper function from Bezier library instead of emulating it by constructing a huge line
- docs: path.intersect... methods never return false, they simply return an empty array in case of no intersection
2024-10-03 11:37:55 +02:00

43 lines
874 B
Text

---
title: utils.beamsIntersect()
---
The `utils.beamsIntersect()` function finds the intersection between two endless
lines (beams). Returns a [Point](/reference/api/point) object for the
intersection, or `false` if the lines don't intersect.
## Signature
```js
Point | false utils.beamsIntersect(
Point A,
Point B,
Point C,
Point D
)
```
## Example
<Example caption="A Utils.beamsIntersect() example">
```js
({ Point, points, Path, paths, Snippet, snippets, utils, part }) => {
points.A = new Point(10, 10)
points.B = new Point(50, 40)
points.C = new Point(45, 20)
points.D = new Point(60, 15)
paths.AB = new Path().move(points.A).line(points.B)
paths.CD = new Path().move(points.C).line(points.D)
snippets.x = new Snippet(
"notch",
utils.beamsIntersect(points.A, points.B, points.C, points.D)
)
return part
}
```
</Example>