示例#1
0
 public void PlotFunction()
 {
     CurrentFunction.CalcFunctionPoints();
     if (functionDrawer != null)
     {
         if (CurrentFunction is HenonFunction curr)
         {
             try {
                 if (curr.MaxIterations > 1000000 && functionDrawer.MainImage.Height == Constants.UsedBSize)
                 {
                     BSize = 2 * Constants.UsedBSize;
                 }
                 else
                 {
                     if (curr.MaxIterations <= 1000000 && functionDrawer.MainImage.Height == 2 * Constants.UsedBSize)
                     {
                         BSize = Constants.UsedBSize;
                     }
                 }
             }
             catch { }
         }
         else
         {
             try {
                 if (functionDrawer.MainImage.Height > Constants.UsedBSize)
                 {
                     BSize = Constants.UsedBSize;
                 }
             }
             catch { }
         }
         functionDrawer.DrawPicture();
     }
 }
        //необходима оптимизация
        public void CreateSchedule(string curFunc)
        {
            CurrentFunction = ConvertInputText(curFunc);
            if (CurrentFunction == null)
            {
                mainChart.Series[2].Points.Clear();
                return;
            }

            if (mainChart.Series[2].Points.Count != 0)
            {
                mainChart.Series[2].Points.Clear();
            }
            double min = CurrentFunction.Contains("log") || CurrentFunction.Contains("log10") ?
                         mainChart.ChartAreas[0].AxisX.Minimum * -0.0001 : mainChart.ChartAreas[0].AxisX.Minimum;
            double max = min < 0 ? min + mainChart.ChartAreas[0].AxisX.Maximum * 2 : mainChart.ChartAreas[0].AxisX.Maximum;

            if (CurrentFunction.Contains("1/tan"))
            {
                for (double i = min; i < 10; i += 0.01)
                {
                    mainChart.Series[2].Points.AddXY(Math.Round(i, 2), CalculateByPoint(i));
                }
                //производная графика ctg(x) являтся график -1/(sin(x))^2
                //шаг на графике PI, начиная с PI
                NormalizeCtg(min, max);
                CurrentFunction = CurrentFunction.Replace("1/tan", "ctg");
                if (CurrentFunction.Contains("tan"))
                {
                    CurrentFunction = CurrentFunction.Replace("ctg", "1/tan");
                    NormalizeTg(min, max);
                }
                return;
            }
            if (CurrentFunction.Contains("tan"))
            {
                //CurrentFunction = CurrentFunction.Replace("ctg", "1/tan");
                for (double i = min; i < max; i += 0.01)
                {
                    mainChart.Series[2].Points.AddXY(Math.Round(i, 2), Math.Round(CalculateByPoint(i), 6));
                }
                //производная графика tg(x) являтся график 1/(cos(x))^2
                //шаг на графике PI, начиная с PI/2
                NormalizeTg(min, max);
                return;
            }
            if (mainChart.Series[2].Points.Count == 0)
            {
                for (double i = min; i < max; i += 0.05)
                {
                    double y = CalculateByPoint(i);
                    mainChart.Series[2].Points.AddXY(i, y > 1000 ? 1000 : y);
                    if (double.IsNaN(y) || double.IsInfinity(y))
                    {
                        mainChart.Series[2].Points[mainChart.Series[2].Points.Count - 1].IsEmpty = true;
                    }
                }
            }
        }
示例#3
0
 public void SetFInclude(int f, bool v)
 {
     FIncludes[f] = v;
     CurrentFunction.FunctionGenerations[f] = v;
     if (v)
     {
         CurrentFunction.CalcFunctionPoints();
         PlotFunction();
     }
 }
示例#4
0
        private void ParamChoice2Form(decimal Par)
        {
            decimal currentPar = CurrentFunction.Parameter;

            CurrentFunction.Parameter = Par;
            CurrentFunction.CalcFunctionPoints();
            diagramFunctionPlotter.Function = CurrentFunction;

            diagramFunctionPlotter.Form2Plot = null;//just to be sure
            diagramFunctionPlotter.DrawPicture();
            PlotForm.SetFunctionImage = diagramFunctionPlotter.MainImage;
            CurrentFunction.Parameter = currentPar;
        }
示例#5
0
        public static bool ExecuteSteps()
        {
            if (IgorAssert.HasJobFailed())
            {
                IgorDebug.CoreLogError("Job failed so we are bailing out early and not finishing the remaining steps!");

                return(false);
            }

            List <StepID> SortedSteps = new List <StepID>(JobSteps.Keys);

            SortedSteps.Sort();

            IgorJobConfig.SetIsRunning(true);

            int StartingPriority        = IgorJobConfig.GetLastPriority();
            int StartingIndexInPriority = IgorJobConfig.GetLastIndexInPriority();

            foreach (StepID CurrentStep in SortedSteps)
            {
                if (CurrentStep.StepPriority > StartingPriority)
                {
                    IgorJobConfig.SetLastPriority(CurrentStep.StepPriority - 1);

                    int LastIndex = 0;

                    List <JobStep> CurrentStepFuncs = JobSteps[CurrentStep];

                    foreach (JobStep CurrentFunction in CurrentStepFuncs)
                    {
                        if (LastIndex > StartingIndexInPriority)
                        {
                            if (CurrentFunction.StepFunction())
                            {
                                IgorJobConfig.SetLastIndexInPriority(LastIndex);
                            }

                            return(false);
                        }

                        ++LastIndex;
                    }

                    StartingIndexInPriority = -1;
                    IgorJobConfig.SetLastIndexInPriority(-1);
                }
            }

            return(true);
        }
 protected void SetTestOutput(Label label)
 {
     label.Text = string.Format(
         "<b>{0}</b>: {1} | {2} | {3} | {4}<br/>Parent: {5} | {6} | {7}<br/>HasReturned: {8}",
         label.ID,
         CurrentFunction.GetType().Name,
         WxeContext.Current.PostBackID,
         CurrentFunction.FunctionToken,
         CurrentPageStep.Page,
         CurrentFunction.ParentFunction != null ? CurrentFunction.ParentFunction.GetType().Name : "&lt;none&gt;",
         CurrentFunction.ParentFunction != null ? CurrentFunction.ParentFunction.FunctionToken : "&lt;none&gt;",
         CurrentFunction.ParentFunction != null ? ((WxePageStep)CurrentFunction.ParentStep).Page : "&lt;none&gt;",
         IsReturningPostBack);
 }
示例#7
0
 public void SetDiagram(IDiagramView diagram)//, bool Ap, bool Bp, bool Cp) {
 {
     if (Control4DiagramView != null)
     {
         Control4DiagramView.ParNum          = 0;// ParNum;
         Control4DiagramView.CurrentFunction = CurrentFunction.Clone();
         if (Control4DiagramView.CurrentFunction is HenonFunction)
         {
             Control4DiagramView.DiagramStopParameter = 0;
         }
         else
         {
             Control4DiagramView.DiagramStopParameter = CurrentFunction.DiagramStop;
         }
         Control4DiagramView.DiagramStartParameter = CurrentFunction.DiagramStart;
         Control4DiagramView.SetDiagram(diagram);
     }
 }
示例#8
0
        public override IElement Evaluate(IElement[] Arguments, Variables Variables)
        {
            long N;
            int  dimx, dimy;
            int  i, c;
            int  Seed;

            i = 0;
            c = Arguments.Length;
            N = (long)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            if (N <= 0)
            {
                throw new ScriptRuntimeException("N in calls to EstimateFlameSize() must be a positive integer.", this);
            }

            object Obj = Arguments[i].AssociatedObjectValue;
            string FunctionsExpression = this.Arguments[i++].SubExpression;

            if (!(Obj is Array FlameArray))
            {
                throw new ScriptRuntimeException("the second parameter to EstimateFlameSize must be an array, containing flame definitions.", this);
            }

            List <FlameFunction> FlameFunctions = new List <FlameFunction>();
            DoubleMatrix         M;
            double        Weight;
            FlameFunction CurrentFunction = null;

            foreach (object FlameItem in FlameArray)
            {
                if (FlameItem is DoubleMatrix)
                {
                    M = (DoubleMatrix)FlameItem;
                    CurrentFunction = new FlameFunction(M, this);
                    FlameFunctions.Add(CurrentFunction);
                }
                else if (FlameItem is SKColor || FlameItem is string)
                {
                    if (CurrentFunction is null)
                    {
                        M = new DoubleMatrix(new double[, ] {
                            { 1, 0 }, { 0, 1 }
                        });
                        CurrentFunction = new FlameFunction(M, this);
                        FlameFunctions.Add(CurrentFunction);
                    }

                    SKColor cl = Graph.ToColor(FlameItem);
                    cl.ToHsl(out float H, out float S, out float L);

                    CurrentFunction.SetColorHsl(H, S, L);
                }
                else if (FlameItem is IFlameVariation)
                {
                    if (CurrentFunction is null)
                    {
                        M = new DoubleMatrix(new double[, ] {
                            { 1, 0 }, { 0, 1 }
                        });
                        CurrentFunction = new FlameFunction(M, this);
                        FlameFunctions.Add(CurrentFunction);
                    }

                    CurrentFunction.Add((IFlameVariation)FlameItem);
                }
                else if (FlameItem is ILambdaExpression)
                {
                    if (CurrentFunction is null)
                    {
                        M = new DoubleMatrix(new double[, ] {
                            { 1, 0 }, { 0, 1 }
                        });
                        CurrentFunction = new FlameFunction(M, this);
                        FlameFunctions.Add(CurrentFunction);
                    }

                    CurrentFunction.Add((ILambdaExpression)FlameItem);
                }
                else
                {
                    try
                    {
                        Weight = Expression.ToDouble(FlameItem);

                        if (CurrentFunction is null)
                        {
                            M = new DoubleMatrix(new double[, ] {
                                { 1, 0 }, { 0, 1 }
                            });
                            CurrentFunction = new FlameFunction(M, this);
                            FlameFunctions.Add(CurrentFunction);
                        }

                        CurrentFunction.SetWeight(Weight);
                    }
                    catch (Exception)
                    {
                        throw new ScriptRuntimeException("Invalid flame variation definition.", this);
                    }
                }
            }

            if (i < c)
            {
                dimx = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                dimx = 320;
            }

            if (i < c)
            {
                dimy = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                dimy = 200;
            }

            if (i < c)
            {
                Seed = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                lock (gen)
                {
                    Seed = gen.Next();
                }

                Variables.ConsoleOut.WriteLine("Seed = " + Seed.ToString(), Variables);
            }

            if (i < c)
            {
                throw new ScriptRuntimeException("Parameter mismatch in call to EstimateFlameSize(N,FlameFunctions[dimx[,dimy[,Seed]]]).",
                                                 this);
            }

            if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
            {
                throw new ScriptRuntimeException("Image size must be within 1x1 to 5000x5000", this);
            }

            FlameFunction[] Functions = FlameFunctions.ToArray();

            FlameFractalRgba.EstimateSize(out double xc, out double yc, out double dr, Functions, dimx, dimy, Seed, N, Variables, this);

            return(new DoubleVector(xc, yc, dr));
        }
示例#9
0
        public override IElement Evaluate(IElement[] Arguments, Variables Variables)
        {
            double xc, yc;
            double dr;
            long   N;
            int    dimx, dimy;
            int    i, c;
            int    Seed;
            bool   Preview;
            bool   Parallel;

            i  = 0;
            c  = Arguments.Length;
            xc = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            yc = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            dr = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            N  = (long)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            if (N <= 0)
            {
                throw new ScriptRuntimeException("N in calls to FlameFractalHsl() must be a positive integer.", this);
            }

            object Obj = Arguments[i].AssociatedObjectValue;
            string FunctionsExpression = this.Arguments[i++].SubExpression;

            if (!(Obj is Array FlameArray))
            {
                throw new ScriptRuntimeException("the fifth parameter to FlameFractal must be an array, containing flame definitions.", this);
            }

            List <FlameFunction> FlameFunctions = new List <FlameFunction>();
            DoubleMatrix         M;
            double        Weight;
            double        Gamma;
            double        LightFactor;
            int           SuperSampling;
            FlameFunction CurrentFunction = null;

            foreach (object FlameItem in FlameArray)
            {
                if (FlameItem is DoubleMatrix)
                {
                    M = (DoubleMatrix)FlameItem;
                    CurrentFunction = new FlameFunction(M, this);
                    FlameFunctions.Add(CurrentFunction);
                }
                else if (FlameItem is SKColor || FlameItem is string)
                {
                    if (CurrentFunction == null)
                    {
                        M = new DoubleMatrix(new double[, ] {
                            { 1, 0 }, { 0, 1 }
                        });
                        CurrentFunction = new FlameFunction(M, this);
                        FlameFunctions.Add(CurrentFunction);
                    }

                    SKColor cl = Graph.ToColor(FlameItem);
                    cl.ToHsl(out float H, out float S, out float L);

                    CurrentFunction.SetColorHsl(H, S, L);
                }
                else if (FlameItem is IFlameVariation)
                {
                    if (CurrentFunction == null)
                    {
                        M = new DoubleMatrix(new double[, ] {
                            { 1, 0 }, { 0, 1 }
                        });
                        CurrentFunction = new FlameFunction(M, this);
                        FlameFunctions.Add(CurrentFunction);
                    }

                    CurrentFunction.Add((IFlameVariation)FlameItem);
                }
                else if (FlameItem is ILambdaExpression)
                {
                    if (CurrentFunction == null)
                    {
                        M = new DoubleMatrix(new double[, ] {
                            { 1, 0 }, { 0, 1 }
                        });
                        CurrentFunction = new FlameFunction(M, this);
                        FlameFunctions.Add(CurrentFunction);
                    }

                    CurrentFunction.Add((ILambdaExpression)FlameItem);
                }
                else
                {
                    try
                    {
                        Weight = Expression.ToDouble(FlameItem);

                        if (CurrentFunction == null)
                        {
                            M = new DoubleMatrix(new double[, ] {
                                { 1, 0 }, { 0, 1 }
                            });
                            CurrentFunction = new FlameFunction(M, this);
                            FlameFunctions.Add(CurrentFunction);
                        }

                        CurrentFunction.SetWeight(Weight);
                    }
                    catch (Exception)
                    {
                        throw new ScriptRuntimeException("Invalid flame variation definition.", this);
                    }
                }
            }

            if (i < c && Arguments[i] is BooleanValue)
            {
                Preview = (bool)Arguments[i++].AssociatedObjectValue;
            }
            else
            {
                Preview = false;
            }

            if (i < c && Arguments[i] is BooleanValue)
            {
                Parallel = (bool)Arguments[i++].AssociatedObjectValue;
            }
            else
            {
                Parallel = false;
            }

            if (i < c)
            {
                dimx = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                dimx = 320;
            }

            if (i < c)
            {
                dimy = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                dimy = 200;
            }

            if (i < c)
            {
                SuperSampling = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                SuperSampling = 2;
            }

            if (i < c)
            {
                Gamma = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                Gamma = 2.2;
            }

            if (i < c)
            {
                LightFactor = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                LightFactor = 1.0;
            }

            if (i < c)
            {
                Seed = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
            }
            else
            {
                lock (gen)
                {
                    Seed = gen.Next();
                }

                Variables.ConsoleOut.WriteLine("Seed = " + Seed.ToString(), Variables);
            }

            if (i < c)
            {
                throw new ScriptRuntimeException("Parameter mismatch in call to FlameFractalHsl(xc,yc,dr,N,FlameFunctions[,Preview[,Parallel[,dimx[,dimy[,SuperSampling[,Gamma[,LightFactor[,Seed]]]]]]]]).",
                                                 this);
            }

            if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
            {
                throw new ScriptRuntimeException("Image size must be within 1x1 to 5000x5000", this);
            }

            FlameFunction[] Functions = FlameFunctions.ToArray();

            if (dr <= 0)
            {
                FlameFractalRgba.EstimateSize(out xc, out yc, out dr, Functions, dimx, dimy, Seed, 5000, Variables, this);

                Variables.ConsoleOut.WriteLine("X-center: " + Expression.ToString(xc), Variables);
                Variables.ConsoleOut.WriteLine("Y-center: " + Expression.ToString(yc), Variables);
                Variables.ConsoleOut.WriteLine("Width: " + Expression.ToString(dr), Variables);
            }

            return(CalcFlame(xc, yc, dr, N, Functions, dimx, dimy, Seed, SuperSampling, Gamma, LightFactor, Preview, Parallel, Variables, this,
                             this.FractalZoomScript, new object[] { dimx, dimy, N, FunctionsExpression, Seed, SuperSampling, Gamma, LightFactor, Preview, Parallel }));
        }
示例#10
0
 protected override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     Stack.Text = string.Join("</br>", CurrentFunction.CreateSequence(f => f.ParentFunction).Select(f => f.GetType().Name));
 }