/// <summary> /// Resuelve el parametro de la clotoide dado los radios <c>r0</c> y <c>r1</c> Con una distancia <c>d</c> entre los /// puntos. /// </summary> private static double SolveParam(double d, double r0, double r1) { Func <double, double> f = (a) => { double fs0, fc0; ClothoUtils.Fresnel(a / (r0 * sqrtpi), out fs0, out fc0); double fs1, fc1; ClothoUtils.Fresnel(a / (r1 * sqrtpi), out fs1, out fc1); double fc10 = (fc1 - fc0); double fs10 = (fs1 - fs0); return(a * a * SysMath.PI * (fc10 * fc10 + fs10 * fs10) - d * d); }; int maxEval = 50; // 30 try { double min = 0; double max = SysMath.Min(SysMath.Abs(r0), SysMath.Abs(r1)) * ClothoUtils.MAX_L; double v = Solver.Solve(f, min, max, Solver.Type.BrentSolver, DEFAULT_ABSOLUTE_ACCURACY, maxEval); return(v); } catch (Exception e) { Debug.WriteLine(e); throw; } }
/// <summary> /// Resuelve el parametro de la clotoide dado los radios <c>r0</c> y <c>r1</c> Con una distancia <c>d</c> entre los /// puntos. /// </summary> private static double SolveParam(double d, double r0, double r1) { Func <double, double> f = (a) => { double fs0, fc0; ClothoUtils.Fresnel(a / (r0 * sqrtpi), out fs0, out fc0); double fs1, fc1; ClothoUtils.Fresnel(a / (r1 * sqrtpi), out fs1, out fc1); double fc10 = (fc1 - fc0); double fs10 = (fs1 - fs0); return(a * a * SysMath.PI * (fc10 * fc10 + fs10 * fs10) - d * d); }; //UnivariateSolver solver = new BisectionSolver(DEFAULT_ABSOLUTE_ACCURACY); //UnivariateSolver solver = new SecantSolver(DEFAULT_ABSOLUTE_ACCURACY); UnivariateSolver solver = new BrentSolver(DEFAULT_ABSOLUTE_ACCURACY); int maxEval = 50; // 30 try { double v = solver.solve(maxEval, new DelegateUnivariateFunction(f), 0, SysMath.Min(SysMath.Abs(r0), SysMath.Abs(r1)) * ClothoUtils.MAX_L); return(v); } catch (TooManyEvaluationsException e) { Console.WriteLine(e); throw; } }