Exemple #1
0
 private void CalculatePoints() {
     int n = _steps * sp.Count;
     _pointsView = new List<PointF>(n);
     _pointsView.Add(new PointF(sp[0].X, sp[0].Func()));
     i_points = new List<PointF>(n);
     d_points = new List<PointF>(n);
     SplineFunction pf_prev = null;
     float y = 0, y0 = 0, y1;
     foreach (var pf in sp) {
         if (sp.IndexOf(pf) > 0) {
             float part = (pf.X - pf_prev.X) / _steps; //длина шага на i-ом сплайне
             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));
                 //if (j < _steps - 1) {
                     y = pf.D_Func(X);
                     d_points.Add(new PointF(X, y));
                 y = -y1 + y0 + pf.I_Func(X);// - part*(j+1));
                     i_points.Add(new PointF(X, y));
                 //}
             }
             y0 = y;
         }
         pf_prev = pf;
     }
 }
Exemple #2
0
        private void CreateSF() {
            sp = new List<SplineFunction>();
            SplineFunction prev = null;
            foreach (var pt in _points) {
                var sp1 = new SplineFunction {
                    //P = pt,
                    X = pt.X,
                    A = pt.Y
                };
                if (_points.IndexOf(pt) > 0) {
                        sp1.H = pt.X - prev.X;
                }
                sp.Add(sp1);
                prev = sp1;
            }

            if (sp.Count == 0)
                throw new InvalidOperationException("List is empty");
            sp[0].C = 0;
            sp[sp.Count - 1].C = 0;
        }