From fa5ba4e63b7cdb581ee03cf7f7a00b7ce4941873 Mon Sep 17 00:00:00 2001 From: ChenX_AMD Date: Tue, 3 Jul 2018 23:13:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E5=8E=9F=E5=85=88=E7=9A=84?= =?UTF-8?q?=E5=9C=A8=E7=AB=AF=E7=82=B9=E4=B8=8A=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?,=E4=BD=BF=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Geometry/__snapshots__/arc.test.ts.snap | 4 ++ __test__/Geometry/arc.test.ts | 9 +++++ src/DatabaseServices/Arc.ts | 39 ++++++++++++++----- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/__test__/Geometry/__snapshots__/arc.test.ts.snap b/__test__/Geometry/__snapshots__/arc.test.ts.snap index 1d3ac6fbc..6e602d2e2 100644 --- a/__test__/Geometry/__snapshots__/arc.test.ts.snap +++ b/__test__/Geometry/__snapshots__/arc.test.ts.snap @@ -70,6 +70,10 @@ exports[`圆弧合并 1`] = `1`; exports[`圆弧合并 2`] = `0.5`; +exports[`圆弧合并 3`] = `0.5`; + +exports[`圆弧合并 4`] = `0`; + exports[`最近点 1`] = ` Vector3 { "x": 0, diff --git a/__test__/Geometry/arc.test.ts b/__test__/Geometry/arc.test.ts index 9d2a7eddc..694361203 100644 --- a/__test__/Geometry/arc.test.ts +++ b/__test__/Geometry/arc.test.ts @@ -212,6 +212,13 @@ test('圆弧合并', () => expect(arc.StartAngle).toMatchSnapshot(); expect(arc.EndAngle).toMatchSnapshot(); + //终点在里面,起点在外面 + arc = new Arc(new Vector3(), 1, 0, 1).Reverse(); + arc2 = new Arc(new Vector3(), 1, 5, 0.5).Reverse(); + expect(arc.Join(arc2)).toBeTruthy(); + expect(arc.StartAngle).toMatchSnapshot(); + expect(arc.EndAngle).toMatchSnapshot(); + //包含. arc = new Arc(new Vector3(), 1, 0, 1).Reverse(); arc2 = new Arc(new Vector3(), 1, 5, 3); @@ -288,3 +295,5 @@ test('容差相接', () => expect(arc.AllAngle).toBe(Math.PI * 2); }); + +//file.only diff --git a/src/DatabaseServices/Arc.ts b/src/DatabaseServices/Arc.ts index 498c3ff4a..4347e8fba 100644 --- a/src/DatabaseServices/Arc.ts +++ b/src/DatabaseServices/Arc.ts @@ -300,26 +300,47 @@ export class Arc extends Curve let saAllan = this.ComputeAnlge(sa); let eaAllan = this.ComputeAnlge(ea); - if (this.ParamOnCurve(this.GetParamAtAngle(ea)))//this终点对终点 + if (equaln(sa, this.m_StartAngle)) //this起点对起点 { - if (eaAllan < saAllan || equaln(sa, this.m_StartAngle)) + if (eaAllan > allAn) + this.EndAngle = ea; + + return true; + } + else if (equaln(sa, this.m_EndAngle))//this终点对起点 + { + if (eaAllan < allAn || equaln(ea, this.m_StartAngle)) this.ConverToCircle();//圆 - else if (saAllan > allAn) - this.StartAngle = sa; + else + this.EndAngle = ea; + return true; } - else if (this.ParamOnCurve(this.GetParamAtAngle(sa))) //this起点对起点 + else if (equaln(ea, this.StartAngle))//this起点对终点 { - if (eaAllan < allAn) + if (saAllan < allAn) this.ConverToCircle();//圆 + else + this.StartAngle = sa; + return true; + } + else if (equaln(ea, this.m_EndAngle))//this终点对终点 + { + if (saAllan > allAn) + this.StartAngle = sa; + return true; + } + else if (this.ParamOnCurve(this.GetParamAtAngle(sa))) + { + if (eaAllan < saAllan) + this.ConverToCircle(); else if (eaAllan > allAn) this.EndAngle = ea; - return true; } - if (eaAllan < saAllan && saAllan < allAn) + else if (this.ParamOnCurve(this.GetParamAtAngle(ea))) { - this.ConverToCircle();//圆 + this.StartAngle = sa; return true; }