diff --git a/__test__/Booloperate/__snapshots__/bool5.test.ts.snap b/__test__/Booloperate/__snapshots__/bool5.test.ts.snap index 22fa05927..85f2c3b84 100644 --- a/__test__/Booloperate/__snapshots__/bool5.test.ts.snap +++ b/__test__/Booloperate/__snapshots__/bool5.test.ts.snap @@ -1,17 +1,17 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`分裂的点在参数周围 1`] = `5782.013217639177`; +exports[`分裂的点在参数周围 1`] = `"5782.01322"`; -exports[`差集共线(圆) 1`] = `442426.78778792813`; +exports[`差集共线(圆) 1`] = `"442426.78779"`; -exports[`差集错误 1`] = `1216051.1666666665`; +exports[`差集错误 1`] = `"1216051.16667"`; -exports[`差集问题 1`] = `546438.8158863322`; +exports[`差集问题 1`] = `"546438.81589"`; -exports[`弧形板差集 1`] = `165548.3611026407`; +exports[`弧形板差集 1`] = `"165548.36110"`; -exports[`弧形板差集 2`] = `331151.31923948776`; +exports[`弧形板差集 2`] = `"331151.31924"`; -exports[`弧形板差集2 1`] = `165548.36022878048`; +exports[`弧形板差集2 1`] = `"165548.36023"`; -exports[`弧形板差集2 2`] = `331151.3192394876`; +exports[`弧形板差集2 2`] = `"331151.31924"`; diff --git a/__test__/Booloperate/bool5.test.ts b/__test__/Booloperate/bool5.test.ts index 943e13830..b7a762f28 100644 --- a/__test__/Booloperate/bool5.test.ts +++ b/__test__/Booloperate/bool5.test.ts @@ -1,5 +1,6 @@ -import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; import { BoolOpeartionType } from "../../src/GraphicsSystem/BoolOperateUtils"; +import "../../__test__/Utils/jest.util"; +import { LoadRegionsFromFileData } from "../Utils/LoadEntity.util"; test('差集共线(圆)', () => { @@ -10,7 +11,7 @@ test('差集共线(圆)', () => regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract); - expect(regs[0].Area).toMatchSnapshot(); + expect(regs[0].Area).toMatchNumberSnapshot(); }); test('差集问题', () => @@ -21,7 +22,7 @@ test('差集问题', () => regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract); expect(regs[0].ShapeManager.ShapeList.length).toBe(1); expect(regs[0].Explode().length).toBe(16); - expect(regs[0].Area).toMatchSnapshot(); + expect(regs[0].Area).toMatchNumberSnapshot(); }); test("弧形板差集", () => @@ -32,7 +33,7 @@ test("弧形板差集", () => regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract); expect(regs[0].ShapeManager.ShapeList.length).toBe(2); for (let s of regs[0].ShapeManager.ShapeList) - expect(s.Area).toMatchSnapshot(); + expect(s.Area).toMatchNumberSnapshot(); }); test("弧形板差集2", () => { @@ -42,7 +43,7 @@ test("弧形板差集2", () => regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract); expect(regs[0].ShapeManager.ShapeList.length).toBe(2); for (let s of regs[0].ShapeManager.ShapeList) - expect(s.Area).toMatchSnapshot(); + expect(s.Area).toMatchNumberSnapshot(); }); test("差集错误", () => @@ -54,7 +55,7 @@ test("差集错误", () => regs[0].BooleanOper(regs[1], BoolOpeartionType.Subtract); expect(regs[0].ShapeManager.ShapeList.length).toBe(1); for (let s of regs[0].ShapeManager.ShapeList) - expect(s.Area).toMatchSnapshot(); + expect(s.Area).toMatchNumberSnapshot(); }); @@ -68,5 +69,5 @@ test("分裂的点在参数周围", () => regs[0].BooleanOper(regs[1], BoolOpeartionType.Intersection); expect(regs[0].ShapeManager.ShapeList.length).toBe(1); for (let s of regs[0].ShapeManager.ShapeList) - expect(s.Area).toMatchSnapshot(); + expect(s.Area).toMatchNumberSnapshot(); }); diff --git a/__test__/EdgeSealing/EdgeSealing.test.ts b/__test__/EdgeSealing/EdgeSealing.test.ts index d05bf9cd8..eead1c149 100644 --- a/__test__/EdgeSealing/EdgeSealing.test.ts +++ b/__test__/EdgeSealing/EdgeSealing.test.ts @@ -34,7 +34,7 @@ function testBrSealing(br: Board, sealingSize: number[]) } pl.ApplyMatrix(br.OCS); expect(pl.IsClose).toBeTruthy(); - expect(pl.Area).toMatchSnapshot(); + expect(pl.Area).toMatchNumberSnapshot(); } test("常规板件,常规坐标系", () => { diff --git a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap index 62ddc8b1f..c61df9793 100644 --- a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`丢失线段板件 1`] = `554052.5007766777`; +exports[`丢失线段板件 1`] = `"554052.50078"`; -exports[`丢失线段板件 2`] = `398758.8789695821`; +exports[`丢失线段板件 2`] = `"398758.87897"`; exports[`切割残留2个封边厚度的凸角的板件封边 1`] = `"30127.50000"`; @@ -32,31 +32,31 @@ exports[`封边错误板件3 1`] = `"359947.95128"`; exports[`封边错误板件4 1`] = `"30748.99860"`; -exports[`常规板件,常规坐标系 1`] = `716404`; +exports[`常规板件,常规坐标系 1`] = `"716404.00000"`; -exports[`常规板件,常规坐标系 2`] = `711624`; +exports[`常规板件,常规坐标系 2`] = `"711624.00000"`; -exports[`常规板件,常规坐标系 3`] = `712816`; +exports[`常规板件,常规坐标系 3`] = `"712816.00000"`; -exports[`异型板件,常规坐标系 1`] = `2709777.788383215`; +exports[`异型板件,常规坐标系 1`] = `"2709777.78838"`; -exports[`异型板件,常规坐标系 2`] = `2682243.404899421`; +exports[`异型板件,常规坐标系 2`] = `"2682243.40490"`; -exports[`异型板件,常规坐标系 3`] = `2660261.483308104`; +exports[`异型板件,常规坐标系 3`] = `"2660261.48331"`; -exports[`异型板件,常规坐标系 4`] = `2628158.6443366623`; +exports[`异型板件,常规坐标系 4`] = `"2628158.64434"`; -exports[`异型板件,常规坐标系 5`] = `2603082.5519226086`; +exports[`异型板件,常规坐标系 5`] = `"2603082.55192"`; -exports[`异型板件,非常规坐标系 1`] = `75939516.39226124`; +exports[`异型板件,非常规坐标系 1`] = `"75939516.39226"`; -exports[`异型板件,非常规坐标系 2`] = `75863286.03232269`; +exports[`异型板件,非常规坐标系 2`] = `"75863286.03232"`; -exports[`异型板件,非常规坐标系 3`] = `75694680.60847883`; +exports[`异型板件,非常规坐标系 3`] = `"75694680.60848"`; -exports[`异型板件,非相切圆弧 1`] = `635612.2751433642`; +exports[`异型板件,非相切圆弧 1`] = `"635612.27514"`; -exports[`异型板件,非相切圆弧 2`] = `626242.2196800549`; +exports[`异型板件,非相切圆弧 2`] = `"626242.21968"`; exports[`椭圆弧封边 1`] = `"23816.28000"`; diff --git a/__test__/EdgeSealing/__snapshots__/OneEdgeSealing.test.ts.snap b/__test__/EdgeSealing/__snapshots__/OneEdgeSealing.test.ts.snap index 481814c10..cbeb998a1 100644 --- a/__test__/EdgeSealing/__snapshots__/OneEdgeSealing.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/OneEdgeSealing.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`偏移后曲线不闭合的问题 1`] = `"14601.05213"`; +exports[`偏移后曲线不闭合的问题 1`] = `"14601.05210"`; exports[`偏移后曲线不闭合的问题 2`] = `"1271.45304"`; diff --git a/__test__/FeedingToolPath/__snapshots__/FeedingToolPath.test.ts.snap b/__test__/FeedingToolPath/__snapshots__/FeedingToolPath.test.ts.snap index ea4c25a60..167d11c04 100644 --- a/__test__/FeedingToolPath/__snapshots__/FeedingToolPath.test.ts.snap +++ b/__test__/FeedingToolPath/__snapshots__/FeedingToolPath.test.ts.snap @@ -170,9 +170,9 @@ exports[`极限刀半径: 走刀数量 4`] = `1`; exports[`极限刀半径: 走刀数量 5`] = `1`; -exports[`超级复杂造型01 1`] = `"23338.03268"`; +exports[`超级复杂造型01 1`] = `"23338.03269"`; -exports[`超级复杂造型01 2`] = `"11855.39979"`; +exports[`超级复杂造型01 2`] = `"11855.39980"`; exports[`超级复杂造型01 3`] = `"9.89484"`; @@ -250,7 +250,7 @@ exports[`超级复杂造型01 39`] = `"34.11041"`; exports[`超级复杂造型01 40`] = `"3.00516"`; -exports[`超级复杂造型01 41`] = `"3.00516"`; +exports[`超级复杂造型01 41`] = `"3.00517"`; exports[`超级复杂造型01 42`] = `"15.55863"`; diff --git a/__test__/Fillet/ParalleLine.test.ts b/__test__/Fillet/ParalleLine.test.ts index 5207835b4..7b19ec7d9 100644 --- a/__test__/Fillet/ParalleLine.test.ts +++ b/__test__/Fillet/ParalleLine.test.ts @@ -1,10 +1,9 @@ -import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; +import { FilletRes, FilletUtils } from "../../src/Add-on/FilletUtils"; +import { CADFiler } from "../../src/DatabaseServices/CADFiler"; +import { Entity } from "../../src/DatabaseServices/Entity/Entity"; import { Line } from "../../src/DatabaseServices/Entity/Line"; -import { FilletUtils, FilletRes } from "../../src/Add-on/FilletUtils"; import { PromptEntityResult } from "../../src/Editor/PromptResult"; -import { Entity } from "../../src/DatabaseServices/Entity/Entity"; -import { CADFiler } from "../../src/DatabaseServices/CADFiler"; - +import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; function expectEntity(e: Entity) { diff --git a/__test__/Fillet/__snapshots__/polyline.test.ts.snap b/__test__/Fillet/__snapshots__/polyline.test.ts.snap index 9af687144..2619b4686 100644 --- a/__test__/Fillet/__snapshots__/polyline.test.ts.snap +++ b/__test__/Fillet/__snapshots__/polyline.test.ts.snap @@ -1,29 +1,29 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`双圆多段线倒角 1`] = `1208.3752684304045`; +exports[`双圆多段线倒角 1`] = `1208.375268430405`; exports[`双圆多段线倒角 2`] = `1208.3752684304045`; -exports[`双圆多段线倒角 3`] = `1208.3752684304054`; +exports[`双圆多段线倒角 3`] = `1208.375268430404`; -exports[`双圆多段线倒角 4`] = `1208.3752684304045`; +exports[`双圆多段线倒角 4`] = `1208.375268430405`; exports[`双圆多段线倒角 5`] = `1200.7933322000165`; exports[`双圆多段线倒角 6`] = `1200.7933322000165`; -exports[`双圆多段线倒角 7`] = `1200.7933322000167`; +exports[`双圆多段线倒角 7`] = `1200.7933322000165`; -exports[`双圆多段线倒角 8`] = `1200.793332200017`; +exports[`双圆多段线倒角 8`] = `1200.7933322000163`; exports[`多段线闭合标志首尾有弧 1`] = `1357.0494514094473`; -exports[`多段线闭合标志首尾有弧 2`] = `1357.049451409447`; +exports[`多段线闭合标志首尾有弧 2`] = `1357.0494514094478`; exports[`多段线闭合标志首尾有弧 3`] = `1357.049451409447`; exports[`多段线闭合标志首尾有弧 4`] = `1357.0494514094473`; -exports[`多段线首尾倒角有圆弧 1`] = `1682.5946408278246`; +exports[`多段线首尾倒角有圆弧 1`] = `1682.5946408278244`; -exports[`多段线首尾倒角有圆弧 2`] = `1682.5946408278244`; +exports[`多段线首尾倒角有圆弧 2`] = `1682.5946408278246`; diff --git a/__test__/Polyline/__snapshots__/PolylineGetPointAtParam.test.ts.snap b/__test__/Polyline/__snapshots__/PolylineGetPointAtParam.test.ts.snap index 3af8ce047..fac8714b7 100644 --- a/__test__/Polyline/__snapshots__/PolylineGetPointAtParam.test.ts.snap +++ b/__test__/Polyline/__snapshots__/PolylineGetPointAtParam.test.ts.snap @@ -346,7 +346,7 @@ Vector3 { exports[`获得点,来自参数 44`] = ` Vector3 { - "x": 3.5305368692688184, + "x": 3.5305368692688193, "y": 5.47745751406263, "z": 0, } @@ -354,16 +354,16 @@ Vector3 { exports[`获得点,来自参数 45`] = ` Vector3 { - "x": -0.7725424859373684, - "y": 2.377641290737884, + "x": -0.7725424859373695, + "y": 2.3776412907378837, "z": 0, } `; exports[`获得点,来自参数 46`] = ` Vector3 { - "x": 2.622358709262116, - "y": 6.727457514062632, + "x": 2.6223587092621172, + "y": 6.727457514062631, "z": 0, } `; @@ -378,7 +378,7 @@ Vector3 { exports[`获得点,来自参数 48`] = ` Vector3 { - "x": 2.6223587092621163, + "x": 2.6223587092621172, "y": 8.272542485937368, "z": 0, } @@ -386,8 +386,8 @@ Vector3 { exports[`获得点,来自参数 49`] = ` Vector3 { - "x": 2.02254248593737, - "y": 1.469463130731181, + "x": 2.022542485937369, + "y": 1.4694631307311816, "z": 0, } `; @@ -395,7 +395,7 @@ Vector3 { exports[`获得点,来自参数 50`] = ` Vector3 { "x": 3.5305368692688193, - "y": 9.52254248593737, + "y": 9.522542485937368, "z": 0, } `; @@ -862,16 +862,16 @@ Vector3 { exports[`获得点,来自参数 119`] = ` Vector3 { - "x": -2.022542485937367, - "y": 1.4694631307311847, + "x": -2.022542485937368, + "y": 1.4694631307311832, "z": 0, } `; exports[`获得点,来自参数 120`] = ` Vector3 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, "z": 0, } `; @@ -886,7 +886,7 @@ Vector3 { exports[`获得点,来自参数 122`] = ` Vector3 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, "z": 0, } @@ -894,8 +894,8 @@ Vector3 { exports[`获得点,来自参数 123`] = ` Vector3 { - "x": 2.022542485937368, - "y": 1.4694631307311836, + "x": 2.0225424859373673, + "y": 1.4694631307311845, "z": 0, } `; diff --git a/__test__/Polyline/__snapshots__/offset.test.ts.snap b/__test__/Polyline/__snapshots__/offset.test.ts.snap index a2fd9b2fb..0cb1f1a45 100644 --- a/__test__/Polyline/__snapshots__/offset.test.ts.snap +++ b/__test__/Polyline/__snapshots__/offset.test.ts.snap @@ -84,33 +84,33 @@ exports[`圆弧错误连接 1`] = `1`; exports[`圆弧错误连接 2`] = `"3624.05703"`; -exports[`圆求交错误导致的线丢失 1`] = `4148.655275462344`; +exports[`圆求交错误导致的线丢失 1`] = `4148.655275462343`; -exports[`圆求交错误导致的线丢失 2`] = `4425.280774659386`; +exports[`圆求交错误导致的线丢失 2`] = `4425.280774659384`; -exports[`圆求交错误导致的线丢失 3`] = `4021.9003150863045`; +exports[`圆求交错误导致的线丢失 3`] = `4021.9003146960804`; -exports[`圆求交错误导致的线丢失 4`] = `4581.2242286507135`; +exports[`圆求交错误导致的线丢失 4`] = `4581.224228650708`; -exports[`圆求交错误导致的线丢失 5`] = `3900.607880862771`; +exports[`圆求交错误导致的线丢失 5`] = `3900.6078799293005`; -exports[`圆求交错误导致的线丢失 6`] = `4757.468532252452`; +exports[`圆求交错误导致的线丢失 6`] = `4757.468532252447`; -exports[`圆求交错误导致的线丢失 7`] = `3783.7486256305697`; +exports[`圆求交错误导致的线丢失 7`] = `3783.7486269392593`; -exports[`圆求交错误导致的线丢失 8`] = `4972.0124797019525`; +exports[`圆求交错误导致的线丢失 8`] = `4972.012479701948`; -exports[`圆求交错误导致的线丢失 9`] = `1148.6626298786346`; +exports[`圆求交错误导致的线丢失 9`] = `1148.662629878697`; -exports[`圆求交错误导致的线丢失 10`] = `5979.881805331884`; +exports[`圆求交错误导致的线丢失 10`] = `5979.881803017036`; -exports[`圆求交错误导致的线丢失 11`] = `1049.9590630920934`; +exports[`圆求交错误导致的线丢失 11`] = `1049.9590630921507`; -exports[`圆求交错误导致的线丢失 12`] = `6051.226636287796`; +exports[`圆求交错误导致的线丢失 12`] = `6051.226633493529`; -exports[`圆求交错误导致的线丢失 13`] = `722.4732418587959`; +exports[`圆求交错误导致的线丢失 13`] = `722.4732418587947`; -exports[`圆求交错误导致的线丢失 14`] = `6316.980880964776`; +exports[`圆求交错误导致的线丢失 14`] = `6316.980878376697`; exports[`复杂圆盘选点 1`] = `1`; @@ -178,13 +178,13 @@ exports[`点在多段线内 2`] = `"1589.94630"`; exports[`简单图形因为点在线内算法错误导致的丢失 1`] = `8.675189454805244`; -exports[`简单图形因为点在线内算法错误导致的丢失 2`] = `8.252841733482935`; +exports[`简单图形因为点在线内算法错误导致的丢失 2`] = `8.252841733482933`; exports[`简单图形因为点在线内算法错误导致的丢失 3`] = `7.149404849854285`; -exports[`简单图形因为点在线内算法错误导致的丢失 4`] = `6.693604273021889`; +exports[`简单图形因为点在线内算法错误导致的丢失 4`] = `6.693604273021893`; -exports[`精度过高导致无法连接 1`] = `"6723.54626"`; +exports[`精度过高导致无法连接 1`] = `"6723.54630"`; exports[`精度过高导致的曲线丢失 1`] = `1`; @@ -196,19 +196,19 @@ exports[`精度过高导致的曲线丢失 4`] = `"97661.61008"`; exports[`精度过高导致直连失败 1`] = `1`; -exports[`精度过高导致直连失败 2`] = `"32040.01360"`; +exports[`精度过高导致直连失败 2`] = `"32040.01389"`; exports[`精度过高导致直连失败 3`] = `1`; -exports[`精度过高导致直连失败 4`] = `"32045.24887"`; +exports[`精度过高导致直连失败 4`] = `"32045.24857"`; exports[`精度过高导致连接失败 1`] = `1`; -exports[`精度过高导致连接失败 2`] = `"75154.17818"`; +exports[`精度过高导致连接失败 2`] = `"75154.17787"`; exports[`精度过高导致连接失败 3`] = `1`; -exports[`精度过高导致连接失败 4`] = `"91209.36322"`; +exports[`精度过高导致连接失败 4`] = `"91209.36321"`; exports[`精度问题导致的连接错误 1`] = `2`; @@ -224,9 +224,9 @@ exports[`纯圆生成的多段线偏移 3`] = `1`; exports[`纯圆生成的多段线偏移 4`] = `"6328.57819"`; -exports[`补充bug测试 1`] = `7385.123391644352`; +exports[`补充bug测试 1`] = `7385.123391644355`; -exports[`补充bug测试 2`] = `7455.861403941375`; +exports[`补充bug测试 2`] = `7455.861403941377`; exports[`补圆弧测试 补圆弧测试1 1`] = `1`; @@ -340,12 +340,12 @@ exports[`连续丢圆弧后无法连接 9`] = `"574.66475"`; exports[`连续丢圆弧后无法连接 10`] = `"574.66475"`; -exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 1`] = `54789.24964851236`; +exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 1`] = `54789.24964851246`; -exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 2`] = `54907.28173780605`; +exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 2`] = `54907.28173780616`; exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 3`] = `55497.50212266887`; -exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 4`] = `56678.241066044844`; +exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 4`] = `56678.24106604484`; -exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 5`] = `57859.37443960543`; +exports[`闭合多段线判断精度和重复交点参数导致偏移丢失 5`] = `57859.374439605526`; diff --git a/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap b/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap index 34b95a9c0..edd0b7426 100644 --- a/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap +++ b/__test__/Polyline/__snapshots__/offsetbug.test.ts.snap @@ -1,10 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`补充bug测试#IKWGF 1`] = `0.4457395323075094`; +exports[`补充bug测试#IKWGF 1`] = `0.4457395323616311`; exports[`补充bug测试#IKWGF 2`] = `10.732981364094256`; -exports[`补充bug测试#IKWGF 3`] = `1.1376403544773557`; +exports[`补充bug测试#IKWGF 3`] = `1.1376403544773555`; exports[`补充bug测试#IKWGF 4`] = `12.786911814880932`; @@ -18,7 +18,7 @@ exports[`补充bug测试#IKWGF 8`] = `11.89101792289923`; exports[`补充bug测试#IKWGF 9`] = `2.168984971098264`; -exports[`补充bug测试#IKWGF 10`] = `0.394745939839015`; +exports[`补充bug测试#IKWGF 10`] = `0.39474593983901435`; exports[`补充bug测试#IKWGF 11`] = `10.69886845125427`; diff --git a/__test__/Polyline/__snapshots__/split.test.ts.snap b/__test__/Polyline/__snapshots__/split.test.ts.snap index 079bffd4f..0875a8ece 100644 --- a/__test__/Polyline/__snapshots__/split.test.ts.snap +++ b/__test__/Polyline/__snapshots__/split.test.ts.snap @@ -153,7 +153,7 @@ Array [ Object { "bul": -0.41421356237309503, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -195,7 +195,7 @@ Array [ Object { "bul": 0, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -356,8 +356,8 @@ Array [ Object { "bul": 0, "pt": Vector2 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, }, }, ] @@ -368,14 +368,14 @@ Array [ Object { "bul": -0.2400787590801159, "pt": Vector2 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, }, }, Object { "bul": 0, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -387,7 +387,7 @@ Array [ Object { "bul": -0.2400787590801159, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -541,8 +541,8 @@ Array [ Object { "bul": 0, "pt": Vector2 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, }, }, ] @@ -553,14 +553,14 @@ Array [ Object { "bul": -0.2400787590801159, "pt": Vector2 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, }, }, Object { "bul": 0, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -572,7 +572,7 @@ Array [ Object { "bul": -0.2400787590801159, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -707,8 +707,8 @@ Array [ Object { "bul": 0, "pt": Vector2 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, }, }, ] @@ -719,14 +719,14 @@ Array [ Object { "bul": -0.2400787590801159, "pt": Vector2 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, }, }, Object { "bul": 0, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -738,7 +738,7 @@ Array [ Object { "bul": -0.2400787590801159, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -880,8 +880,8 @@ Array [ Object { "bul": 0, "pt": Vector2 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, }, }, ] @@ -892,14 +892,14 @@ Array [ Object { "bul": -0.2400787590801159, "pt": Vector2 { - "x": 3.530536869268815, - "y": 5.477457514062634, + "x": 3.5305368692688175, + "y": 5.477457514062632, }, }, Object { "bul": 0, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, @@ -911,7 +911,7 @@ Array [ Object { "bul": -0.2400787590801159, "pt": Vector2 { - "x": 2.5, + "x": 2.500000000000001, "y": 7.5, }, }, diff --git a/__test__/Sweep/__snapshots__/SweepSegs.test.ts.snap b/__test__/Sweep/__snapshots__/SweepSegs.test.ts.snap index de30a3245..b0b794363 100644 --- a/__test__/Sweep/__snapshots__/SweepSegs.test.ts.snap +++ b/__test__/Sweep/__snapshots__/SweepSegs.test.ts.snap @@ -1,28 +1,28 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`顶线分段测试 不闭合多补圆弧 1`] = `7527.309534097056`; +exports[`顶线分段测试 不闭合多补圆弧 1`] = `7527.309534097063`; -exports[`顶线分段测试 不闭合多补圆弧 2`] = `181.5491080422332`; +exports[`顶线分段测试 不闭合多补圆弧 2`] = `181.54910804222436`; exports[`顶线分段测试 不闭合多补圆弧 3`] = `7972.744263135363`; -exports[`顶线分段测试 不闭合多补圆弧 4`] = `175.55938663598863`; +exports[`顶线分段测试 不闭合多补圆弧 4`] = `175.5593866359881`; -exports[`顶线分段测试 不闭合多补圆弧 5`] = `9102.215223601412`; +exports[`顶线分段测试 不闭合多补圆弧 5`] = `9102.21522360141`; -exports[`顶线分段测试 不闭合多补圆弧 6`] = `174.8880833875115`; +exports[`顶线分段测试 不闭合多补圆弧 6`] = `174.8880833875153`; -exports[`顶线分段测试 不闭合多补圆弧 7`] = `9850.281806459632`; +exports[`顶线分段测试 不闭合多补圆弧 7`] = `9850.281806459629`; -exports[`顶线分段测试 不闭合多补圆弧 8`] = `167.51636096659317`; +exports[`顶线分段测试 不闭合多补圆弧 8`] = `167.5163609665956`; exports[`顶线分段测试 不闭合多补圆弧 9`] = `9201.576517258296`; -exports[`顶线分段测试 不闭合多补圆弧 10`] = `8466.391158009817`; +exports[`顶线分段测试 不闭合多补圆弧 10`] = `8466.391158009821`; -exports[`顶线分段测试 不闭合多补圆弧 11`] = `13771.549281343938`; +exports[`顶线分段测试 不闭合多补圆弧 11`] = `13771.549281343903`; -exports[`顶线分段测试 不闭合多补圆弧 12`] = `8903.394215503109`; +exports[`顶线分段测试 不闭合多补圆弧 12`] = `8903.394215503084`; exports[`顶线分段测试 不闭合直线 1`] = `1107.864406779661`; @@ -38,13 +38,13 @@ exports[`顶线分段测试 不闭合直线 6`] = `1341.5593220338988`; exports[`顶线分段测试 不闭合直线 7`] = `1127.7966101694917`; -exports[`顶线分段测试 不闭合直线圆弧 1`] = `2149.5428197912242`; +exports[`顶线分段测试 不闭合直线圆弧 1`] = `2149.542819791226`; -exports[`顶线分段测试 不闭合直线圆弧 2`] = `3886.6189286714834`; +exports[`顶线分段测试 不闭合直线圆弧 2`] = `3886.6189286714807`; -exports[`顶线分段测试 不闭合直线圆弧 3`] = `4288.290679114739`; +exports[`顶线分段测试 不闭合直线圆弧 3`] = `4288.29067911474`; -exports[`顶线分段测试 不闭合直线圆弧 4`] = `2721.960193789363`; +exports[`顶线分段测试 不闭合直线圆弧 4`] = `2721.960193789361`; exports[`顶线分段测试 不闭合直线圆弧 5`] = `2351.778679840207`; @@ -52,33 +52,33 @@ exports[`顶线分段测试 不闭合直线圆弧 6`] = `4128.24578371541`; exports[`顶线分段测试 不闭合直线圆弧2 1`] = `4393.076886867966`; -exports[`顶线分段测试 不闭合直线圆弧2 2`] = `6.5660240646022485`; +exports[`顶线分段测试 不闭合直线圆弧2 2`] = `6.566024064602179`; -exports[`顶线分段测试 不闭合直线圆弧2 3`] = `8562.229412244691`; +exports[`顶线分段测试 不闭合直线圆弧2 3`] = `8562.229412244687`; -exports[`顶线分段测试 不闭合直线圆弧2 4`] = `7775.242286971556`; +exports[`顶线分段测试 不闭合直线圆弧2 4`] = `7775.24228697155`; -exports[`顶线分段测试 不闭合直线圆弧2 5`] = `7158.345287787591`; +exports[`顶线分段测试 不闭合直线圆弧2 5`] = `7158.345287787588`; -exports[`顶线分段测试 不闭合直线圆弧2 6`] = `11250.987271676091`; +exports[`顶线分段测试 不闭合直线圆弧2 6`] = `11250.987271676096`; -exports[`顶线分段测试 闭合圆弧 1`] = `183.06306067445354`; +exports[`顶线分段测试 闭合圆弧 1`] = `183.06306067444856`; exports[`顶线分段测试 闭合圆弧 2`] = `5822.513453880229`; -exports[`顶线分段测试 闭合圆弧 3`] = `6427.17494400804`; +exports[`顶线分段测试 闭合圆弧 3`] = `6427.174944008036`; -exports[`顶线分段测试 闭合圆弧 4`] = `9954.439545178488`; +exports[`顶线分段测试 闭合圆弧 4`] = `9954.439545178504`; exports[`顶线分段测试 闭合圆弧 5`] = `5190.973862843558`; -exports[`顶线分段测试 闭合圆弧 6`] = `7730.5776753028`; +exports[`顶线分段测试 闭合圆弧 6`] = `7730.577675302795`; -exports[`顶线分段测试 闭合圆弧 7`] = `14243.520190228804`; +exports[`顶线分段测试 闭合圆弧 7`] = `14243.520190228797`; -exports[`顶线分段测试 闭合圆弧 8`] = `11360.44019007804`; +exports[`顶线分段测试 闭合圆弧 8`] = `11360.440190078047`; -exports[`顶线分段测试 闭合圆弧 9`] = `4713.854133052737`; +exports[`顶线分段测试 闭合圆弧 9`] = `4713.85413305274`; exports[`顶线分段测试 闭合直线 1`] = `2152.655017660556`; diff --git a/src/DatabaseServices/Entity/Arc.ts b/src/DatabaseServices/Entity/Arc.ts index 06e89814b..ecdf3135c 100644 --- a/src/DatabaseServices/Entity/Arc.ts +++ b/src/DatabaseServices/Entity/Arc.ts @@ -4,7 +4,7 @@ import { matrixSetVector, reviseMirrorMatrix } from '../../Common/Matrix4Utils'; import { Status } from '../../Common/Status'; import { ObjectSnapMode } from '../../Editor/ObjectSnapMode'; import { Box3Ext } from '../../Geometry/Box'; -import { angle, AsVector3, clampRad, equaln, equalv2, equalv3, midPoint, MoveMatrix, polar, ZeroVec } from '../../Geometry/GeUtils'; +import { angle, AsVector3, clampRad, equaln, equalv2, equalv3, MoveMatrix, polar, ZeroVec } from '../../Geometry/GeUtils'; import { IntersectArcAndArc, IntersectCircleAndArc, IntersectEllipseAndCircleOrArc, IntersectLineAndArc, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption } from '../../GraphicsSystem/IntersectWith'; import { Factory } from '../CADFactory'; import { CADFiler } from '../CADFiler'; @@ -528,7 +528,7 @@ export class Arc extends Curve /** * 解析两点和凸度所构成的圆弧 - * + * ref http://www.lee-mac.com/bulgeconversion.html * @param {Vector2} p1 * @param {Vector2} p2 * @param {number} bul 凸度,在cad中,凸度为 <(四分之一圆心角)的正切值> @@ -544,33 +544,22 @@ export class Arc extends Curve p1 = p1.clone().applyMatrix4(ocsInv); p2 = p2.clone().applyMatrix4(ocsInv); - //弦向量 - let chordV = p2.clone().sub(p1); - //弦角度 - let chordAn = angle(chordV); - //弦长度/2 - let chordLengthHalf = chordV.length() / 2; - - let allAngle = Math.atan(bul) * 4; - let HalfAngle = allAngle * 0.5; - //半径 - this._Radius = chordLengthHalf / Math.sin(HalfAngle); - - //指向圆心的角度 - let toCenterAn = chordAn + Math.PI * 0.5;//弦角度转90 + //a (* 2 (atan b)) + let a = Math.atan(bul) * 2; + //r (/ (distance p1 p2) 2 (sin a)) + let r = p1.distanceTo(p2) / 2 / Math.sin(a); + //c (polar p1 (+ (- (/ pi 2) a) (angle p1 p2)) r) + let c = polar(p1.clone(), Math.PI / 2 - a + angle(p2.clone().sub(p1)), r); - //圆心 - let center = midPoint(p1, p2); - polar(center, toCenterAn, this._Radius - (bul * chordLengthHalf)); - this.Center = center.clone().applyMatrix4(this.OCS); - - this._Radius = Math.abs(this._Radius); + this._Radius = Math.abs(r); - this._StartAngle = angle(p1.clone().sub(center)); - this._EndAngle = angle(p2.clone().sub(center)); + this._StartAngle = angle(p1.sub(c)); + this._EndAngle = angle(p2.sub(c)); this._Clockwise = bul < 0; + this.Center = c.applyMatrix4(this.OCSNoClone); + return this; } FromThreePoint(pt1: Vector3, pt2: Vector3, pt3: Vector3)