Ejemplo n.º 1
0
        public DrawerModel GetDrawerData(Factor factors, double start, double end, double step)
        {
            var drawModel = new DrawerModel();

            for (double x = start; x <= end; x += step)
            {
                double y = 0;

                factors.Terms.ForEach(term =>
                {
                    if (term.Symbol != default(char))
                    {
                        y += ((term.Sign == Sign.Plus) ? term.Number : -term.Number) * Math.Pow(x, term.SymbolsPower);
                    }
                    else
                    {
                        y += (term.Sign == Sign.Plus) ? term.Number : -term.Number;
                    }
                });

                drawModel.AddData(x, y);
            }

            return(drawModel);
        }
Ejemplo n.º 2
0
        public DrawerModel GetGraphicDataFromFunction(dynamic algorithm, IUserAlgorithmStrategyProvider strategyProvider, UserAlgorithmStore store)
        {
            var drawerModel = new DrawerModel();

            if (algorithm == null)
            {
                return(drawerModel);
            }

            ExecuteAlgorithm(algorithm.Algorithm, strategyProvider, store);
            var returnVariable = store.ReturnVariable;

            var xs = store.ListVariables["x"];
            var ys = store.ListVariables["y"];

            if (xs.Count != ys.Count)
            {
                throw new Exception("Mistake in Graphic builder algorithm");
            }

            for (var i = 0; i < xs.Count; i++)
            {
                drawerModel.AddData(xs[i], ys[i]);
            }

            return(drawerModel);
        }
Ejemplo n.º 3
0
        public DrawerModel GetGraphicDataFromSetOfPoints(dynamic setOfPoints, IUserAlgorithmStrategyProvider strategyProvider, UserAlgorithmStore store)
        {
            var drawerModel = new DrawerModel();

            if (setOfPoints == null)
            {
                return(drawerModel);
            }

            var points = setOfPoints.ToObject <PointModel[]>();

            (points as PointModel[]).ToList().ForEach(point =>
            {
                drawerModel.AddData(point.X, point.Y);
            });

            return(drawerModel);
        }