mirror of https://gitee.com/cf-fz/WebCAD.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.6 KiB
34 lines
1.6 KiB
import { Ellipse } from "../../src/DatabaseServices/Entity/Ellipse";
|
|
import { Line } from "../../src/DatabaseServices/Entity/Line";
|
|
import { equaln } from "../../src/Geometry/GeUtils";
|
|
import { IntersectOption } from "../../src/GraphicsSystem/IntersectWith";
|
|
import { LoadEntityFromFileData } from '../Utils/LoadEntity.util';
|
|
|
|
test('椭圆参数翻转', () =>
|
|
{
|
|
let d =
|
|
{ "file": [2, "Ellipse", 10, 2, 104, 0, 1, 1, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1040.8072063493028, -838.5276872436621, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -935.6208801731591, -1701.2048253468238, 0, 1], 0, 0, 1, 1, 1215.639217876851, 614.2902515010619, 5.498368818682524, 0, 0, "Line", 10, 2, 107, 0, 1, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 1, [850.3191623444072, -2510.7929602864897, 0], [435.01033264443686, 871.6945624563377, 0]], "basePt": { "x": 78.50807304852151, "y": -2510.7929602864897, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
|
|
|
|
let [el, line] = LoadEntityFromFileData(d) as [Ellipse, Line];
|
|
|
|
let ipts = el.IntersectWith2(line, IntersectOption.ExtendNone);
|
|
|
|
|
|
for (let d of ipts)
|
|
{
|
|
let pt = el.GetPointAtParam(d.thisParam);
|
|
let param = el.GetParamAtPoint(d.pt);
|
|
|
|
expect(pt.equals(d.pt));
|
|
expect(param).toBe(d.thisParam);
|
|
}
|
|
|
|
for (let i = 0; i < 10; i++)
|
|
{
|
|
let p = el.GetPointAtParam(i / 10);
|
|
expect(p.toArray()).toMatchSnapshot();
|
|
let param = el.GetParamAtPoint(p);
|
|
expect(equaln(param, i / 10)).toBeTruthy();
|
|
}
|
|
});
|