Exemple #1
0
        public static void SolveDirectProblem()
        {
            double radius       = 2;
            int    pointsNumber = 32;

            //IDirectProblemTestData testData = new PlanarTestData();
            //IDirectProblemTestData testData = new FundamentalSolutionTestData();
            var outerCurve = new StarCurve((t) => radius);
            IDirectProblemTestData testData = new FundamentalSolutionDevidedTastData(outerCurve);
            //IDirectProblemTestData testData = new CoordinatesDeviationDoubleTestData();
            DirectProblemState  state  = new DirectProblemState(radius, pointsNumber, testData);
            DirectProblemSolver solver = new DirectProblemSolver(state);

            Printer.Append = false;
            Printer.Mode   = WriteMode.Console;
            double[] density = solver.CalculateDensity();
            Printer.WriteLine("Density :");
            Printer.Write(density);
            double[] solution = solver.BuildSolutionOn(density,
                                                       xFunc: SolutionCurveX,
                                                       yFunc: SolutionCurveY,
                                                       paramStart: 0.001,
                                                       paramEnd: Math.PI - 0.001,
                                                       solutionPointsNumber: 16);

            DeviationCalculator calculator = new DeviationCalculator();
            double deviation = calculator.MaxDeviation(
                solution,
                accurate: (double t) =>
            {
                Point x = new Point(SolutionCurveX(t), SolutionCurveY(t));
                return(testData.OnTestCurveValue(x));
            },
                paramStart: 0.001,
                paramEnd: Math.PI - 0.001);

            Printer.Append = true;
            Printer.WriteLine("Solution :");
            Printer.Write(solution);
            Printer.WriteLine($"Deviation : {deviation}");
            Console.ReadLine();
        }
Exemple #2
0
 public DirectProblemSolver(DirectProblemState state)
 {
     _state = state;
 }