You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/__test__/Interest/line.test.ts

46 lines
1.3 KiB

import { Line } from "../../src/DatabaseServices/Line";
import { Vector3 } from "three";
import { IntersectLineAndLine, Intersect } from "../../src/GraphicsSystem/IntersectWith"
test('直线相交,共线', () =>
{
let l1 = new Line(new Vector3(0, 0, 0), new Vector3(5, 0, 0));
let l2 = new Line(new Vector3(10, 0, 0), new Vector3(15, 0, 0));
let pts = IntersectLineAndLine(l1, l2, Intersect.ExtendThis);
expect(pts.length).toBe(0);
pts = IntersectLineAndLine(l1, l2, Intersect.OnBothOperands);
expect(pts.length).toBe(0);
pts = IntersectLineAndLine(l1, l2, Intersect.ExtendArg);
expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, Intersect.ExtendBoth);
expect(pts.length).toBe(1);
});
test('直线相交', () =>
{
let l1 = new Line(new Vector3(0, 0, 0), new Vector3(5, 5, 0));
let l2 = new Line(new Vector3(5, 0, 0), new Vector3(0, 5, 0));
let pts = IntersectLineAndLine(l1, l2, Intersect.ExtendThis);
expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, Intersect.OnBothOperands);
expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, Intersect.ExtendArg);
expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, Intersect.ExtendBoth);
expect(pts.length).toBe(1);
});