fix: Increase iteration on curve intersection calc (#10707)
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
@@ -428,50 +428,3 @@ exports[`restoreElements > should restore text element correctly with unknown fo
|
|||||||
"y": 0,
|
"y": 0,
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`restoreElements > should strip arrow binding if repair throws 1`] = `
|
|
||||||
{
|
|
||||||
"angle": 0,
|
|
||||||
"backgroundColor": "transparent",
|
|
||||||
"boundElements": [],
|
|
||||||
"customData": undefined,
|
|
||||||
"elbowed": false,
|
|
||||||
"endArrowhead": null,
|
|
||||||
"endBinding": null,
|
|
||||||
"fillStyle": "solid",
|
|
||||||
"frameId": null,
|
|
||||||
"groupIds": [],
|
|
||||||
"height": 100,
|
|
||||||
"id": "id-arrow01",
|
|
||||||
"index": "a0",
|
|
||||||
"isDeleted": false,
|
|
||||||
"link": null,
|
|
||||||
"locked": false,
|
|
||||||
"opacity": 100,
|
|
||||||
"points": [
|
|
||||||
[
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
100,
|
|
||||||
100,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
|
||||||
"roundness": null,
|
|
||||||
"seed": Any<Number>,
|
|
||||||
"startArrowhead": null,
|
|
||||||
"startBinding": null,
|
|
||||||
"strokeColor": "#1e1e1e",
|
|
||||||
"strokeStyle": "solid",
|
|
||||||
"strokeWidth": 2,
|
|
||||||
"type": "arrow",
|
|
||||||
"updated": 1,
|
|
||||||
"version": 2,
|
|
||||||
"versionNonce": Any<Number>,
|
|
||||||
"width": 100,
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { isPoint, pointDistance, pointFrom, pointFromVector } from "./point";
|
import { isPoint, pointDistance, pointFrom, pointFromVector } from "./point";
|
||||||
import { vector, vectorNormal, vectorNormalize, vectorScale } from "./vector";
|
import { vector, vectorNormal, vectorNormalize, vectorScale } from "./vector";
|
||||||
import { LegendreGaussN24CValues, LegendreGaussN24TValues } from "./constants";
|
import { LegendreGaussN24CValues, LegendreGaussN24TValues } from "./constants";
|
||||||
import { lineSegment, lineSegmentIntersectionPoints } from "./segment";
|
|
||||||
|
|
||||||
import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
|
import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
|
||||||
|
|
||||||
@@ -139,7 +138,7 @@ const calculate = <Point extends GlobalPoint | LocalPoint>(
|
|||||||
l: LineSegment<Point>,
|
l: LineSegment<Point>,
|
||||||
c: Curve<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) {
|
if (!solution) {
|
||||||
return null;
|
return null;
|
||||||
@@ -175,23 +174,6 @@ export function curveIntersectLineSegment<
|
|||||||
return [solution];
|
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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user