mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-16 14:00:56 +02:00
feat: Remove GA code from binding (#9042)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { line, linesIntersectAt } from "./line";
|
||||
import {
|
||||
isPoint,
|
||||
pointCenter,
|
||||
@@ -27,14 +28,6 @@ export function lineSegment<P extends GlobalPoint | LocalPoint>(
|
||||
return [a, b] as LineSegment<P>;
|
||||
}
|
||||
|
||||
export function lineSegmentFromPointArray<P extends GlobalPoint | LocalPoint>(
|
||||
pointArray: P[],
|
||||
): LineSegment<P> | undefined {
|
||||
return pointArray.length === 2
|
||||
? lineSegment<P>(pointArray[0], pointArray[1])
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param segment
|
||||
@@ -156,3 +149,26 @@ export const distanceToLineSegment = <Point extends LocalPoint | GlobalPoint>(
|
||||
const dy = y - yy;
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the intersection point of a segment and a line
|
||||
*
|
||||
* @param l
|
||||
* @param s
|
||||
* @returns
|
||||
*/
|
||||
export function lineSegmentIntersectionPoints<
|
||||
Point extends GlobalPoint | LocalPoint,
|
||||
>(l: LineSegment<Point>, s: LineSegment<Point>): Point | null {
|
||||
const candidate = linesIntersectAt(line(l[0], l[1]), line(s[0], s[1]));
|
||||
|
||||
if (
|
||||
!candidate ||
|
||||
!pointOnLineSegment(candidate, s) ||
|
||||
!pointOnLineSegment(candidate, l)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
Reference in New Issue
Block a user