More intersection detection functions

This commit is contained in:
Mark Tolmacs 2024-09-30 15:31:02 +02:00
parent b7f504796b
commit 6e67aa3a3c
No known key found for this signature in database
4 changed files with 75 additions and 12 deletions

View file

@ -6,7 +6,7 @@ import {
pointRotateRads,
pointsEqual,
} from "./point";
import type { GenericPoint, Segment, Radians, Line } from "./types";
import type { GenericPoint, Segment, Radians } from "./types";
import { PRECISION } from "./utils";
import {
vectorAdd,
@ -180,15 +180,10 @@ export function segmentDistanceToPoint<Point extends GenericPoint>(
}
/**
* Returns the intersection point between a segment and a line, if any
* Returns the intersection point of a segment and a line
*
* @param s
* @param l
* @param s
* @returns
*/
export function segmentIntersectsLine<Point extends GenericPoint>(
s: Segment<Point>,
l: Line<Point>,
): Point | null {
return lineIntersectsSegment(l, s);
}
export const segmentIntersectsLine = lineIntersectsSegment;