diff --git a/__test__/Polyline/PointInPolyline.test.ts b/__test__/Polyline/PointInPolyline.test.ts index 157892baa..5d6abb912 100644 --- a/__test__/Polyline/PointInPolyline.test.ts +++ b/__test__/Polyline/PointInPolyline.test.ts @@ -179,7 +179,7 @@ describe("", () => expect(pl.PtInCurve(p)).toBeFalsy(); }); - test('同样是因为精度导致的错误IKOTO', () => + test('圆弧起点切线与直线相切IKOTO', () => { let f = new CADFile(); f.Data = @@ -192,4 +192,18 @@ describe("", () => expect(pl.PtInCurve(p)).toBeFalsy(); }); + + test('大圆弧', () => + { + + let f = new CADFile(); + f.Data = + [1, ["Polyline", 1, 1, 5, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 3, [5.113122171945702, 3.235294117647059], 2.037852023242286, [6.69683257918552, 0.7918552036199095], 0, [5.113122171945702, 3.235294117647059], 0, false]] + let p = new Vector3().fromArray([5.113122171945701, 0.7239819004524888, 0]); + + f.Read(); + let pl = f.ReadObject() as Polyline; + expect(pl.PtInCurve(p)).toBeTruthy(); + }); + }) diff --git a/src/DatabaseServices/PointInPolyline.ts b/src/DatabaseServices/PointInPolyline.ts index 06f7ab7cf..b13a62e62 100644 --- a/src/DatabaseServices/PointInPolyline.ts +++ b/src/DatabaseServices/PointInPolyline.ts @@ -84,12 +84,16 @@ export function IsPointInPolyLine(pl: Polyline, pt: Vector3): boolean if (equal(pti, cu.StartPoint)) { let der = cu.GetFistDeriv(0); + if (equaln(der.x, 0) && cu instanceof Arc) + der = cu.GetFistDeriv(0.1); if (der.x < -1e-4) //左边+ 右边0 crossings++; } else if (equal(pti, cu.EndPoint)) { let der = cu.GetFistDeriv(1); + if (equaln(der.x, 0) && cu instanceof Arc) + der = cu.GetFistDeriv(0.9); if (der.x > 1e-4) //左边+ 右边0 crossings++; }