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.OnBothOperands); 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.OnBothOperands); 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); });