import { Vector3 } from 'three'; import { Line } from '../../src/DatabaseServices/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(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, 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); });