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

52 lines
1.5 KiB

import { Vector3 } from 'three';
import { Line } from '../../src/DatabaseServices/Entity/Line';
import { IntersectLineAndLine, IntersectOption } 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, IntersectOption.ExtendThis);
expect(pts.length).toBe(0);
pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendNone);
expect(pts.length).toBe(0);
pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendArg);
expect(pts.length).toBe(0);
pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendBoth);//?
expect(pts.length).toBe(4);
});
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, IntersectOption.ExtendThis);
expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendNone);
expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendArg);
expect(pts.length).toBe(1);
pts = IntersectLineAndLine(l1, l2, IntersectOption.ExtendBoth);
expect(pts.length).toBe(1);
});
test('直线参数', () =>
{
let l1 = new Line(new Vector3(0, 0, 0), new Vector3(5, 5, 0));
expect(l1.GetClosestAtPoint(new Vector3(10, 10), false).param).toBe(1);
});