Virtual whiteboard for sketching hand-drawn like diagrams
fix: Increase iteration on curve intersection calc (#10707)
Márk Tolmács54fa0c908969
diff --git a/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap b/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snapindex 802edcc373..e3c0581522 100644--- a/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap+++ b/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap@@ -428,50 +428,3 @@ exports[`restoreElements > should restore text element correctly with unknown fo"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,-}-`;diff --git a/packages/math/src/curve.ts b/packages/math/src/curve.tsindex 55db76877e..32f537f434 100644--- a/packages/math/src/curve.ts+++ b/packages/math/src/curve.ts@@ -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 [];}