修正点在线内算法错误的问题

pull/68/head
ChenX_AMD 6 years ago
parent 31f62c6280
commit be6b66d9be

@ -164,4 +164,19 @@ describe("", () =>
expect(pl.PtInCurve(p)).toBeFalsy();
});
test('精度过低导致的错误', () =>
{
let f = new CADFile();
f.Data =
[1, ["Polyline", 1, 1, 18237, false, 2, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.7938671363300003, 0.39666461398798525, 0, 1], 2, 5, [12.414545456418505, 8.796498405316765], 0, [12.015990240675425, 8.743859037199755], 0, [12.23362472371057, 8.552710046188702], 0, [12.233990240675425, 8.552758322014249], 0, [12.414545456418505, 8.796498405316765], 0, false]]
let p = new Vector3().fromArray([13.027857377005425, 8.947146562082409, 0]);
f.Read();
let pl = f.ReadObject() as Polyline;
pl.PtInCurve(p);//?
});
})

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

Loading…
Cancel
Save