From 514ddf1169771b6d31926827524c20264ae43ef5 Mon Sep 17 00:00:00 2001 From: ChenX Date: Thu, 5 Jul 2018 15:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=9B=A0=E4=B8=BA=E7=B2=BE?= =?UTF-8?q?=E5=BA=A6=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E7=9A=84=20?= =?UTF-8?q?=E7=82=B9=E5=9C=A8=E5=A4=9A=E6=AE=B5=E7=BA=BF=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Polyline/PointInPolyline.test.ts | 15 +++++++++++++++ src/DatabaseServices/PointInPolyline.ts | 8 ++++---- 2 files changed, 19 insertions(+), 4 deletions(-) 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;