mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Tune what's considered a duplicate intersection point
This commit is contained in:
parent
df1f89efcd
commit
2cf53200ac
2 changed files with 6 additions and 3 deletions
|
@ -234,7 +234,8 @@ const intersectRectanguloidWithLineSegment = (
|
||||||
)
|
)
|
||||||
// Remove duplicates
|
// Remove duplicates
|
||||||
.filter(
|
.filter(
|
||||||
(p, idx, points) => points.findIndex((d) => pointsEqual(p, d)) === idx,
|
(p, idx, points) =>
|
||||||
|
points.findIndex((d) => pointsEqual(p, d, 1e-3)) === idx,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -282,7 +283,8 @@ const intersectDiamondWithLineSegment = (
|
||||||
)
|
)
|
||||||
// Remove duplicates
|
// Remove duplicates
|
||||||
.filter(
|
.filter(
|
||||||
(p, idx, points) => points.findIndex((d) => pointsEqual(p, d)) === idx,
|
(p, idx, points) =>
|
||||||
|
points.findIndex((d) => pointsEqual(p, d, 1e-3)) === idx,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,9 +91,10 @@ export function isPoint(p: unknown): p is LocalPoint | GlobalPoint {
|
||||||
export function pointsEqual<Point extends GlobalPoint | LocalPoint>(
|
export function pointsEqual<Point extends GlobalPoint | LocalPoint>(
|
||||||
a: Point,
|
a: Point,
|
||||||
b: Point,
|
b: Point,
|
||||||
|
precision = PRECISION,
|
||||||
): boolean {
|
): boolean {
|
||||||
const abs = Math.abs;
|
const abs = Math.abs;
|
||||||
return abs(a[0] - b[0]) < PRECISION && abs(a[1] - b[1]) < PRECISION;
|
return abs(a[0] - b[0]) < precision && abs(a[1] - b[1]) < precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue