コード例 #1
0
        //расчёт точек для построения кривой
        private PointF[] GetPoints(double a, double b, int numberOfPoints, string func)
        {
            double step = Math.Abs(b - a) / numberOfPoints;

            PointF[] points = new PointF[numberOfPoints];
            for (int i = 0; i <= numberOfPoints; i++)
            {
                string x = Convert.ToString(a + i * step);
                parser.ProgrammaticallyParse("let x = " + x.ToString().Replace(",", "."));
                if (i == numberOfPoints)
                {
                    points[i - 1] = new PointF(float.Parse(x), (float)parser.Parse(func.Replace(",", ".")));
                }
                else
                {
                    points[i] = new PointF(float.Parse(x), (float)parser.Parse(func.Replace(",", ".")));
                }
            }

            return(points);
        }