Get three solutions for curve-line intersections to avoid issue with high inclination intersectors

This commit is contained in:
Mark Tolmacs 2025-03-24 15:24:06 +01:00
parent 4d1e2c2bbb
commit 4ee99de2fb
3 changed files with 9 additions and 17 deletions

View file

@ -157,22 +157,13 @@ export function curveIntersectLineSegment<
return bezierEquation(c, t);
};
let solution = calculate(initial_guesses[0]);
if (solution) {
return [solution];
}
const solutions = [
calculate(initial_guesses[0]),
calculate(initial_guesses[1]),
calculate(initial_guesses[2]),
].filter((x, i, a): x is Point => x !== null && a.indexOf(x) === i);
solution = calculate(initial_guesses[1]);
if (solution) {
return [solution];
}
solution = calculate(initial_guesses[2]);
if (solution) {
return [solution];
}
return [];
return solutions;
}
/**