{
Solver solver = new Solver(x0, v0, mu, steps);
Process gnuplot = Gnuplot(mu);
- //Console.WriteLine("{0} results", solver.Result.Count);
- int i = 0;
foreach (Coord coord in solver.Result)
{
gnuplot.StandardInput.WriteLine("{0:0.000}\t{1:0.000}", coord.X, coord.Y);
- ++i;
}
gnuplot.StandardInput.Close();
gnuplot.WaitForExit();
using System;
using System.Collections.Generic;
+using System.Diagnostics;
namespace MervsSolver
{
double mu = continuousParameter;
double d = stepSize;
- double[] A = new double[300];
- double[] E = new double[300];
- double b = 0, c = 0, z = 0, s = 0, h = 0, x1 = 0, v1 = 0;
- int i = 0;
+ double[] A = new double[50+1];
+ double[] E = new double[50+1];
+ double z = 0;
if (v0 < 0)
- goto Line320;
- if (v0 > 0)
- goto Line300;
- if (x0 > 0)
- goto Line320;
- Line300:
- z = d;
- goto Line330;
- Line320:
- z = -d;
- Line330:
- x1 = x0 + z;
- b = equation(v0, z, mu, x1);
- c = z * x1;
- s = (b * b) - 4 * c;
- if (s < 0)
- goto Line540;
- double k = z / Math.Abs(z);
- v1 = (-b + k * Math.Sqrt((b * b) - 4 * c)) / 2;
- Line430:
- i = i + 1;
- A[i] = x1;
- E[i] = v1;
- h = h + 1;
- if (h == 50)
- goto Line590;
- Line480:
- v0 = v1;
- x0 = x1;
- if (v0 == 0)
- goto Line520;
- goto Line330;
- Line520:
- if (i == 0 || i > 500)
- return;
- if (E[i - 1] < 0)
- goto Line300;
- goto Line320;
- Line540:
- z = z / 10;
- if (Math.Abs(z) < 1.0e-3)
- goto Line570;
- goto Line330;
- Line570:
- v1 = 0;
- goto Line430;
- Line590:
- for (i = 1; i != h; ++i)
- mResult.Add(new Coord(0 + (A[i] * -75), (E[i] * -75)));
- h = 0; i = 0;
- goto Line480;
+ z = -d;
+ else if (v0 > 0)
+ z = d;
+ else if (x0 > 0)
+ z = -d;
+ else
+ z = d;
+
+ int i = 0;
+ while (true)
+ {
+ double v1;
+ double x1 = x0 + z;
+ double b = equation(v0, z, mu, x1);
+ double c = z * x1;
+ double s = (b * b) - 4 * c;
+ if (s < 0)
+ {
+ z = z / 10;
+ if (Math.Abs(z) >= 1.0e-3)
+ continue;
+ v1 = 0;
+ }
+ else
+ {
+ double k = z / Math.Abs(z);
+ v1 = (-b + k * Math.Sqrt((b * b) - 4 * c)) / 2;
+ }
+ i = i + 1;
+ A[i] = x1;
+ E[i] = v1;
+ if (i == 50)
+ {
+ for (int n = 1; n != i; ++n)
+ mResult.Add(new Coord(0 + (A[n] * -75), (E[n] * -75)));
+ i = 0;
+ }
+ v0 = v1;
+ x0 = x1;
+ if (v0 == 0)
+ {
+ if (i == 0 || mResult.Count > 1000)
+ break;
+ if (E[i - 1] < 0)
+ z = d;
+ else
+ z = -d;
+ }
+ }
}
static double equation(double v0, double z, double mu, double x1)