fix: Increase iteration on curve intersection calc (#10707)

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Márk Tolmács
2026-01-26 20:52:13 +01:00
committed by GitHub
parent dfdd994dbb
commit 54fa0c9089
2 changed files with 1 additions and 66 deletions
+1 -19
View File
@@ -1,7 +1,6 @@
import { isPoint, pointDistance, pointFrom, pointFromVector } from "./point";
import { vector, vectorNormal, vectorNormalize, vectorScale } from "./vector";
import { LegendreGaussN24CValues, LegendreGaussN24TValues } from "./constants";
import { lineSegment, lineSegmentIntersectionPoints } from "./segment";
import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
@@ -139,7 +138,7 @@ const calculate = <Point extends GlobalPoint | LocalPoint>(
l: LineSegment<Point>,
c: Curve<Point>,
) => {
const solution = solveWithAnalyticalJacobian(c, l, t0, s0, 1e-2, 3);
const solution = solveWithAnalyticalJacobian(c, l, t0, s0, 1e-2, 4);
if (!solution) {
return null;
@@ -175,23 +174,6 @@ export function curveIntersectLineSegment<
return [solution];
}
// Fallback: approximate the curve with short segments to catch near-endpoint hits.
const startHit = lineSegmentIntersectionPoints(
lineSegment(bezierEquation(c, 0), bezierEquation(c, 1 / 20)),
l,
);
if (startHit) {
return [startHit];
}
const endHit = lineSegmentIntersectionPoints(
lineSegment(bezierEquation(c, 19 / 20), bezierEquation(c, 1)),
l,
);
if (endHit) {
return [endHit];
}
return [];
}