fix #IKOTO 修正点在多段线内判断,交点在圆弧端点且相切时判断错误的问题.

pull/68/head
ChenX_AMD 6 years ago
parent 01c921fd8d
commit e650cf020e

@ -179,7 +179,7 @@ describe("", () =>
expect(pl.PtInCurve(p)).toBeFalsy(); expect(pl.PtInCurve(p)).toBeFalsy();
}); });
test('同样是因为精度导致的错误IKOTO', () => test('圆弧起点切线与直线相切IKOTO', () =>
{ {
let f = new CADFile(); let f = new CADFile();
f.Data = f.Data =
@ -192,4 +192,18 @@ describe("", () =>
expect(pl.PtInCurve(p)).toBeFalsy(); 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();
});
}) })

@ -84,12 +84,16 @@ export function IsPointInPolyLine(pl: Polyline, pt: Vector3): boolean
if (equal(pti, cu.StartPoint)) if (equal(pti, cu.StartPoint))
{ {
let der = cu.GetFistDeriv(0); let der = cu.GetFistDeriv(0);
if (equaln(der.x, 0) && cu instanceof Arc)
der = cu.GetFistDeriv(0.1);
if (der.x < -1e-4) //左边+ 右边0 if (der.x < -1e-4) //左边+ 右边0
crossings++; crossings++;
} }
else if (equal(pti, cu.EndPoint)) else if (equal(pti, cu.EndPoint))
{ {
let der = cu.GetFistDeriv(1); let der = cu.GetFistDeriv(1);
if (equaln(der.x, 0) && cu instanceof Arc)
der = cu.GetFistDeriv(0.9);
if (der.x > 1e-4) //左边+ 右边0 if (der.x > 1e-4) //左边+ 右边0
crossings++; crossings++;
} }

Loading…
Cancel
Save