对于参数在曲线上,给定指定的容差. 1e-6

pull/72/head
cx 6 years ago
parent 15c6c3ffee
commit 9c6a68b806

@ -2,6 +2,7 @@ import { Vector2, Vector3 } from 'three';
import { Polyline } from '../../src/DatabaseServices/Polyline';
import { equal, equaln } from '../../src/Geometry/GeUtils';
import { CADFile } from '../../src/DatabaseServices/CADFile';
test("多段线点获取参数", () =>
{
@ -470,3 +471,19 @@ describe('多段线', () =>
expect(pl.StartPoint).toEqual(new Vector3(0, 10, 0))
})
})
test('最近点参数刚好在端点上', () =>
{
let f = new CADFile();
f.Data = [1, ["Polyline", 1, 1, 11, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 15.725529745042493, -3.9968028886505635e-15, 0, 1], 2, 3, [13.07875354107649, 3.8181303116147296], 0, [18.159206798866855, 3.8181303116147296], 0.664293193717279, [18.159206798866855, -1.4844192634560907], -0.10977222864644352, false]];
f.Read();
let pl = f.ReadObject() as Polyline;
let p = new Vector3(33.88473654390935, 3.8181303116147256, 0);
let cp = pl.GetClosestPointTo(p, false);
let param = pl.GetParamAtPoint(cp);
expect(equaln(param, 1)).toBeTruthy();
});

@ -117,7 +117,7 @@ export abstract class Curve extends Entity
}
//参数在曲线上
ParamOnCurve(param: number): boolean { return !isNaN(param) && param >= 0 && param <= this.EndParam; }
ParamOnCurve(param: number): boolean { return !isNaN(param) && param >= -1e-8 && param <= this.EndParam + 1e-8; }
GetOffsetCurves(offsetDist: number): Array<Curve> { return; }
GetClosestPointTo(pt: Vector3, extend: boolean): Vector3 { return; }

Loading…
Cancel
Save