Exemplo n.º 1
0
        private void CreateSF()
        {
            splinePoints = new List <SplineFunction>();
            SplineFunction prev = null;

            foreach (var pt in _points)
            {
                var splinePoints1 = new SplineFunction {
                    X = pt.X,
                    A = pt.Y
                };
                if (_points.IndexOf(pt) > 0)
                {
                    splinePoints1.H = pt.X - prev.X;
                }
                splinePoints.Add(splinePoints1);
                prev = splinePoints1;
            }

            if (splinePoints.Count == 0)
            {
                throw new InvalidOperationException("List is empty");
            }
            splinePoints[0].C = 0;
            splinePoints[splinePoints.Count - 1].C = 0;
        }
Exemplo n.º 2
0
        private void CalculatePoints()
        {
            int n = _steps * splinePoints.Count;

            _pointsView = new List <PointF>(n);
            _pointsView.Add(new PointF(splinePoints[0].X, splinePoints[0].Func()));
            iPoints = new List <PointF>(n);
            SplineFunction pf_prev = null;
            float          y = 0, y0 = 0, y1;

            foreach (var pf in splinePoints)
            {
                if (splinePoints.IndexOf(pf) > 0)
                {
                    float part = (pf.X - pf_prev.X) / _steps;
                    float X    = pf_prev.X;
                    y1 = pf.I_Func(X);
                    for (int j = 0; j < _steps; j++)
                    {
                        X += part;
                        y  = pf.Func(X);
                        _pointsView.Add(new PointF(X, y));
                        y = -y1 + y0 + pf.I_Func(X);
                        iPoints.Add(new PointF(X, y));
                    }
                    y0 = y;
                }
                pf_prev = pf;
            }
        }