diff --git a/__test__/Polyline/PointInPolyline.test.ts b/__test__/Polyline/PointInPolyline.test.ts index 5d6abb912..94ebd73b3 100644 --- a/__test__/Polyline/PointInPolyline.test.ts +++ b/__test__/Polyline/PointInPolyline.test.ts @@ -192,6 +192,21 @@ describe("", () => expect(pl.PtInCurve(p)).toBeFalsy(); }); + test('直线和圆弧相切2IKOTO', () => + { + let f = new CADFile(); + f.Data = + [1, ["Polyline", 1, 1, 667, false, 6, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 5, [5135.438782795266, 1651.835443234731], -0.9999915853997117, [5470.58864251807, 1651.8382633987026], 0, [5370.588642280742, 1651.8413831024218], 0.9999560507337252, [5235.438782795266, 1651.835443234731], 0, [5135.438782795266, 1651.835443234731], 0, false]] + + f.Read(); + + let pl = f.ReadObject() as Polyline; + + let p = new Vector3().fromArray([5370.588642541802, -904.7955785523422, 0]); + + expect(pl.PtInCurve(p)).toBeFalsy(); + }); + test('大圆弧', () => { diff --git a/src/DatabaseServices/PointInPolyline.ts b/src/DatabaseServices/PointInPolyline.ts index 7b29e5d32..08c79a442 100644 --- a/src/DatabaseServices/PointInPolyline.ts +++ b/src/DatabaseServices/PointInPolyline.ts @@ -70,7 +70,7 @@ export function IsPointInPolyLine(pl: Polyline, pt: Vector3): boolean for (let i = 0; i < pl.EndParam; i++) { - if (equaln(pl.GetBuilgeAt(i), 0, 1e-7))//直线 + if (equaln(pl.GetBuilgeAt(i), 0, 5e-6))//直线 { let sp = pl.GetPointAtParam(i); let ep = pl.GetPointAtParam(i + 1); @@ -79,17 +79,17 @@ export function IsPointInPolyLine(pl: Polyline, pt: Vector3): boolean continue; //线垂直Y轴 let derX = ep.x - sp.x; - if (equaln(derX, 0, 1e-7)) + if (equaln(derX, 0, 5e-6)) continue; //起点 - if (equaln(sp.x, pt.x, 1e-7)) + if (equaln(sp.x, pt.x, 5e-6)) { if (sp.y > pt.y && derX < 0) crossings++; continue; } //终点 - if (equaln(ep.x, pt.x, 1e-7)) + if (equaln(ep.x, pt.x, 5e-6)) { if (ep.y > pt.y && derX > 0) crossings++; continue;