Replace intersection code

This commit is contained in:
Mark Tolmacs 2024-10-01 16:24:31 +02:00
parent 411deae176
commit 0c02972695
No known key found for this signature in database
18 changed files with 507 additions and 687 deletions

View file

@ -1,11 +1,11 @@
import { line, lineIntersectsLine, lineIntersectsSegment } from "./line";
import { line, lineLineIntersectionPoint, lineSegmentIntersectionPoints } from "./line";
import { point } from "./point";
import { segment } from "./segment";
describe("line-line intersections", () => {
it("should correctly detect intersection at origin", () => {
expect(
lineIntersectsLine(
lineLineIntersectionPoint(
line(point(-5, -5), point(5, 5)),
line(point(5, -5), point(-5, 5)),
),
@ -14,7 +14,7 @@ describe("line-line intersections", () => {
it("should correctly detect intersection at non-origin", () => {
expect(
lineIntersectsLine(
lineLineIntersectionPoint(
line(point(0, 0), point(10, 10)),
line(point(10, 0), point(0, 10)),
),
@ -23,7 +23,7 @@ describe("line-line intersections", () => {
it("should correctly detect parallel lines", () => {
expect(
lineIntersectsLine(
lineLineIntersectionPoint(
line(point(0, 0), point(0, 10)),
line(point(10, 0), point(10, 10)),
),
@ -34,7 +34,7 @@ describe("line-line intersections", () => {
describe("line-segment intersections", () => {
it("should correctly detect intersection", () => {
expect(
lineIntersectsSegment(
lineSegmentIntersectionPoints(
line(point(0, 0), point(5, 0)),
segment(point(2, -2), point(3, 2)),
),
@ -42,7 +42,7 @@ describe("line-segment intersections", () => {
});
it("should correctly detect non-intersection", () => {
expect(
lineIntersectsSegment(
lineSegmentIntersectionPoints(
line(point(0, 0), point(5, 0)),
segment(point(3, 1), point(4, 4)),
),