public static double approximate(double u_l, double u_r, double u_b, double u_t, double h_l, double h_r, double h_b, double h_t, double R) { //Square R if (R != 1) { R = Pow(R, 2); } //create List of points of interest point U_l = new point(u_l, h_l, "x"); point U_r = new point(u_r, h_r, "x"); point U_t = new point(u_t, h_t, "y"); point U_b = new point(u_b, h_b, "y"); point U_lr = U_l.solveIntersectionOfRespLine(U_r); point U_tb = U_t.solveIntersectionOfRespLine(U_b); point[] points = new point[] { U_l, U_r, U_t, U_b, U_lr, U_tb }; Array.Sort(points); #if DEBUG //Throw exception when all Points are undefined; if (points[0].pos == double.MaxValue) { throw new ArgumentException("At least one u_i must be defined"); } if (h_l <= 0 || h_r <= 0 || h_b <= 0 || h_t <= 0) { throw new ArgumentException("H must be > 0"); } #endif //Create function that selects the active conditions in each max() function Eikonal = new function(R); //Check points for (int i = 0; i < points.Length - 1; ++i) { Eikonal.update(points[i]); if (Eikonal.value(points[i + 1]) > R) { return(Eikonal.solve()); } } Eikonal.update(points[points.Length - 1]); return(Eikonal.solve()); }