1
0
Fork 0

Merge pull request #3931 from freesewing/beamIntersectsCurve

utils.beamIntersectsCurve()
This commit is contained in:
Joost De Cock 2023-04-29 20:10:14 +02:00 committed by GitHub
commit 7aed296564
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 153 additions and 0 deletions

View file

@ -111,6 +111,24 @@ export function beamsIntersect(a1, a2, b1, b2) {
}
}
/**
* Find the intersections between an endless line (beam) and a curve
*
*
* @param {Point} start - Start Point of the line
* @param {Point} end - End Point of the line
* @param {Point} from - Start Point of the curve
* @param {Point} cp1 - Control Point at the start of the curve
* @param {Point} cp2 - Control Point at the end of the curve
* @param {Point} to - End Point of the curve
* @return {Array} intersections - An array of Points at the intersections
*/
export function beamIntersectsCurve(start, end, from, cp1, cp2, to) {
let _start = new Point(start.x + (start.x - end.x) * 1000, start.y + (start.y - end.y) * 1000)
let _end = new Point(end.x + (end.x - start.x) * 1000, end.y + (end.y - start.y) * 1000)
return lineIntersectsCurve(_start, _end, from, cp1, cp2, to)
}
/**
* Returns the string you pass with with the first character converted to uppercase
*