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; }