diff options
| author | kj_sh604 | 2026-03-15 16:19:35 -0400 |
|---|---|---|
| committer | kj_sh604 | 2026-03-15 16:19:35 -0400 |
| commit | 6ec259a0e71174651bae95d4628138bf6fd68742 (patch) | |
| tree | 5e33c6a5ec091ecabfcb257fdc7b6a88ed8754ac /packages/math/line.test.ts | |
| parent | 16c8578b15c727f22921f8a80a56ee4d4e7f2272 (diff) | |
refactor: packages/
Diffstat (limited to 'packages/math/line.test.ts')
| -rw-r--r-- | packages/math/line.test.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/math/line.test.ts b/packages/math/line.test.ts new file mode 100644 index 0000000..0e6bb1c --- /dev/null +++ b/packages/math/line.test.ts @@ -0,0 +1,31 @@ +import { line, linesIntersectAt } from "./line"; +import { pointFrom } from "./point"; + +describe("line-line intersections", () => { + it("should correctly detect intersection at origin", () => { + expect( + linesIntersectAt( + line(pointFrom(-5, -5), pointFrom(5, 5)), + line(pointFrom(5, -5), pointFrom(-5, 5)), + ), + ).toEqual(pointFrom(0, 0)); + }); + + it("should correctly detect intersection at non-origin", () => { + expect( + linesIntersectAt( + line(pointFrom(0, 0), pointFrom(10, 10)), + line(pointFrom(10, 0), pointFrom(0, 10)), + ), + ).toEqual(pointFrom(5, 5)); + }); + + it("should correctly detect parallel lines", () => { + expect( + linesIntersectAt( + line(pointFrom(0, 0), pointFrom(0, 10)), + line(pointFrom(10, 0), pointFrom(10, 10)), + ), + ).toBe(null); + }); +}); |
