Example #1
0
 public FractalViewer()
 {
     bitmap          = new Bitmap(ArgsAdapter.GetIntArgs(0), ArgsAdapter.GetIntArgs(1));
     newtonFactorial = new NewtonFractal();
     colors          = new Color[] {
         Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.Orange,
         Color.Fuchsia, Color.Gold, Color.Cyan, Color.Magenta
     };
 }
Example #2
0
 static void Main(string[] args)
 {
     try
     {
         NewtonFractal newtonFractal = new NewtonFractal(args);
         newtonFractal.Iteration.PrintPolynomial();
         newtonFractal.Draw();
         newtonFractal.Save();
     }
     catch (Exception e)
     {
         Console.WriteLine("Error:\n" + e.Message);
     }
     finally
     {
         Console.Write("Press any key to exit the program.");
         Console.ReadKey();
     }
 }
        public FractalAlgorithm GetAutoConfiguredAlgorithmByID(Algorithm algorithmID, params ComplexFunction.ComplexFunction[] Derivatives)
        {
            if (Derivatives.Length == 0)
            {
                return(new NullAlgorithm());
            }

            FractalAlgorithm algorithm;

            switch (algorithmID)
            {
            // actually we really need the derivative so really (... >= 2)
            case Algorithm.Newton:
                if (Derivatives.Length < 2)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[0].GetDerivative() };
                }
                algorithm = new NewtonFractal();
                break;

            case Algorithm.Halley:
                if (Derivatives.Length < 2)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[0].GetDerivative() };
                }
                if (Derivatives.Length < 3)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[1], Derivatives[1].GetDerivative() };
                }
                algorithm = new HalleyFractal();
                break;

            case Algorithm.Quadruple:
                if (Derivatives.Length < 2)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[0].GetDerivative() };
                }
                if (Derivatives.Length < 3)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[1], Derivatives[1].GetDerivative() };
                }
                if (Derivatives.Length < 4)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[1], Derivatives[2], Derivatives[2].GetDerivative() };
                }
                algorithm = new HalleyFractal();
                break;

            case Algorithm.Halley_overnewtoned:
                if (Derivatives.Length < 2)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[0].GetDerivative() };
                }
                if (Derivatives.Length < 3)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[1], Derivatives[1].GetDerivative() };
                }
                algorithm = new HalleyNewton();
                break;

            case Algorithm.Halley_without_derivative:
                algorithm = new HalleyWithoutDerivativeFractal();
                break;

            case Algorithm.Quadratic:
                if (Derivatives.Length < 2)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[0].GetDerivative() };
                }
                if (Derivatives.Length < 3)
                {
                    Derivatives = new ComplexFunction.ComplexFunction[] { Derivatives[0], Derivatives[1], Derivatives[1].GetDerivative() };
                }
                algorithm = new QuadraticFractal();
                break;

            case Algorithm.Quadratic_without_derivative:
                algorithm = new QuadraticWithoutDerivativeFractal();
                break;

            case Algorithm.Newton_without_derivative:
                algorithm = new NewtonWithoutDerivativeFractal();
                break;

            case Algorithm.Secant_Newton_combination:
                algorithm = new SecantNewtonFractal();
                break;

            case Algorithm.Secant:
                algorithm = new SecantFractal();
                break;

            case Algorithm.Muller:
                algorithm = new MullerFractal();
                break;

            case Algorithm.Moler_real:
                algorithm = new MolerRealFractal();
                break;

            case Algorithm.Inverse:
                algorithm = new InverseQuadraticFractal();
                break;

            case Algorithm.Steffensen:
                algorithm = new SteffensenFractal();
                break;

            case Algorithm.Custom:
                algorithm = new CustomFractal();
                break;

            default:
                algorithm = new NullAlgorithm();
                break;
            }

            algorithm.Derivatives           = Derivatives;
            algorithm.MaximumIterationCount = Settings.Instance.iterations;

            if (algorithm is ParametrizedFractalAlgorithm)
            {
                (algorithm as ParametrizedFractalAlgorithm).Parameter = (double)Settings.Instance.parameter;
            }

            return(algorithm);
        }