mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Arc tests
This commit is contained in:
parent
f79fb899fc
commit
3fe73e79a6
9 changed files with 80 additions and 76 deletions
|
@ -1,6 +1,7 @@
|
|||
import { radians } from "./angle";
|
||||
import { arc, arcIncludesPoint } from "./arc";
|
||||
import { arc, arcIncludesPoint, arcSegmentInterceptPoint } from "./arc";
|
||||
import { point } from "./point";
|
||||
import { segment } from "./segment";
|
||||
|
||||
describe("point on arc", () => {
|
||||
it("should detect point on simple arc", () => {
|
||||
|
@ -28,3 +29,26 @@ describe("point on arc", () => {
|
|||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("intersection", () => {
|
||||
it("should report correct interception point", () => {
|
||||
expect(
|
||||
arcSegmentInterceptPoint(
|
||||
arc(point(0, 0), 1, radians(-Math.PI / 4), radians(Math.PI / 4)),
|
||||
segment(point(2, 1), point(0, 0)),
|
||||
),
|
||||
).toEqual([point(0.894427190999916, 0.447213595499958)]);
|
||||
});
|
||||
|
||||
it("should report both interception points when present", () => {
|
||||
expect(
|
||||
arcSegmentInterceptPoint(
|
||||
arc(point(0, 0), 1, radians(-Math.PI / 4), radians(Math.PI / 4)),
|
||||
segment(point(0.9, -2), point(0.9, 2)),
|
||||
),
|
||||
).toEqual([
|
||||
point(0.9, -0.4358898943540668),
|
||||
point(0.9, 0.4358898943540668),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue