public Point2d IntersectionPointC(FuncApproximation F1, FuncApproximation F2, Point2d PtCenter, bool DispB) { Point2d PtA = new Point2d(0, 0), PtB = new Point2d(PtCenter.X * 2, PtCenter.Y * 2); Point2d[] PTlst = new Point2d[9]; while (true) { Lrepeat: double xMin = Min(PtA.X, PtB.X); double xMax = Max(PtA.X, PtB.X); double yMin = Min(PtA.Y, PtB.Y); double yMax = Max(PtA.Y, PtB.Y); double xSpn = (xMax - xMin) * 0.5; double ySpn = (yMax - yMin) * 0.5; if (xSpn < 0.01 && ySpn < 0.01) { break; } WriteLine(); for (int rc = 0; rc < 9; rc++) { PTlst[rc] = new Point2d(xMin + xSpn * (rc % 3), yMin + ySpn * (rc / 3)); } int k = 0; foreach (var P in PTlst) { WriteLine("{4}: {0:000},{1:000} {2:0.00} {3:0.00}", P.X, P.Y, F1.FuncPt2F(P), F2.FuncPt2F(P), ++k); } Combination cmb = new Combination(9, 2); while (cmb.Successor()) { int s0 = cmb.Index[0], s1 = cmb.Index[1]; if (s0 / 3 == s1 / 3 || s0 % 3 == s1 % 3 || Abs((s0 / 3 - s1 / 3) * (s0 % 3 - s1 % 3)) == 4) { continue; } //int s2=s1/3*3+s0%3, s3=s0/3*3+s1%3; //WriteLine(" {0} {1} {2} {3}", s0, s1, s2, s3 ); PtA = PTlst[s0]; PtB = PTlst[s1]; if (F1.FuncPt2F(PtA) * F1.FuncPt2F(PtB) > 0.0) { continue; } if (F2.FuncPt2F(PtA) * F2.FuncPt2F(PtB) > 0.0) { continue; } int s2 = s1 / 3 * 3 + s0 % 3, s3 = s0 / 3 * 3 + s1 % 3; PtA = PTlst[s2]; PtB = PTlst[s3]; if (F1.FuncPt2F(PtA) * F1.FuncPt2F(PtB) > 0.0) { continue; } if (F2.FuncPt2F(PtA) * F2.FuncPt2F(PtB) > 0.0) { continue; } WriteLine(" {0} {1} {2} {3}", s0, s1, s2, s3); goto Lrepeat; } // WriteLine(); // foreach( var P in PTlst) WriteLine("IntersectionPoint "+P ); } return(PtB); }
public Point2d IntersectionPointB(FuncApproximation F1, FuncApproximation F2, Point2d PtCenter, bool DispB) { Point2d PtA = new Point2d(0, 0), PtB = new Point2d(PtCenter.X * 2, PtCenter.Y * 2); Point2d[,] PTlst = new Point2d[3, 3]; while (true) { double xMin = Min(PtA.X, PtB.X); double xMax = Max(PtA.X, PtB.X); double yMin = Min(PtA.Y, PtB.Y); double yMax = Max(PtA.Y, PtB.Y); double xSpn = (xMax - xMin) * 0.5; double ySpn = (yMax - yMin) * 0.5; if (xSpn < 0.01 && ySpn < 0.01) { break; } for (int r = 0; r < 3; r++) { for (int c = 0; c < 3; c++) { PTlst[r, c] = new Point2d(xMin + xSpn * c, yMin + ySpn * r); } } WriteLine(); int k = 0; foreach (var P in PTlst) { WriteLine("{4}: {0:000.00},{1:000.00} {2:0.00} {3:0.00}", P.X, P.Y, F1.FuncPt2F((Point)P), F2.FuncPt2F((Point)P), ++k); } for (int r = 0; r < 2; r++) { for (int c = 0; c < 2; c++) { PtA = PTlst[r, c]; PtB = PTlst[r + 1, c + 1]; if (F1.FuncPt2F((Point)PtA) * F1.FuncPt2F((Point)PtB) > 0.0) { continue; } if (F2.FuncPt2F((Point)PtA) * F2.FuncPt2F((Point)PtB) > 0.0) { continue; } goto LFond; } } for (int r = 0; r < 2; r++) { for (int c = 0; c < 2; c++) { PtA = PTlst[r + 1, c]; PtB = PTlst[r, c + 1]; if (F1.FuncPt2F((Point)PtA) * F1.FuncPt2F((Point)PtB) > 0.0) { continue; } if (F2.FuncPt2F((Point)PtA) * F2.FuncPt2F((Point)PtB) > 0.0) { continue; } goto LFond; } } // WriteLine(); // foreach( var P in PTlst) WriteLine("IntersectionPoint "+P ); LFond: continue; } return(PtB); }