public LagarangePolynomialCurveInterpolatedData(PolynomialCurveParam curveParam)
 {
     this.curveType = curveParam.PolynomialCurveType;
     this.lastPoint = curveParam.PointList.RightBorderPoint;
     this.count = curveParam.Count;
     this.curve = GenerateCurve(curveParam);
 }
Ejemplo n.º 2
0
 public PolynomialCurve(ICurveParam curveParam)
 {
     if (canDrawCurve(curveParam))
     {
         canDraw = true;
         this.curveParam = (PolynomialCurveParam)curveParam;
     }
 }
        private NormalIntervalPolynomialCurveElement GenerateCurve(PolynomialCurveParam curveParam)
        {
            Debug.Assert(curveParam.PolynomialCurveType == PolynomialCurveType.Lagrange, @"This interpolated method """"GenerateCurve"""" only supports Lagarange Polynomial Curve.");
            double[,] coefficientsArray = new double[count, count];
            double[,] constantArray = new double[count, 1];
            double coef, x;
            
            for (int i = 0; i < count; i++)
            {
                constantArray[i, 0] = curveParam[i].Y.AccurateValue;
                coef = 1;
                x = curveParam[i].X.AccurateValue;
                for (int j = 0; j < count; j++)
                {
                    coefficientsArray[i, j] = coef;
                    coef *= x;
                }
            }

            LinearEquationSet equations = new LinearEquationSet(new Matrix(coefficientsArray), new Matrix(constantArray));
            Matrix result = equations.AnswerMatrix;

            List<DoubleExtension> coefs = new List<DoubleExtension>();
            for (int i = 0; i < count; i++)
            {
                coefs.Add(new DoubleExtension(result[i, 0]));
            }
            return new NormalIntervalPolynomialCurveElement(coefs, count, new DataInterval(curveParam.PointList.LeftBorderPoint.X, curveParam.PointList.RightBorderPoint.X)); 
            //OrderedCurvePointList pointList = param.PointList;
            //List<NormalIntervalPolynomialCurveElement> polynomialCurve = new List<NormalIntervalPolynomialCurveElement>();
            //List<DoubleExtension> coefficients = null;
            //List<DoubleExtension> cutPoints = new List<DoubleExtension>();
            //cutPoints.Add(pointList[0].X);
            //for (int i = 2; i < pointList.Count; i = i + 2)
            //{
            //    coefficients = MathExtension.CalculateQuadraticPolynomialCoefficients(pointList[i - 2], pointList[i - 1], pointList[i]);
            //    polynomialCurve.Add(new NormalIntervalPolynomialCurveElement(coefficients, 3, pointList[i - 2].X, pointList[i].X));
            //    cutPoints.Add(pointList[i].X);
            //}
            //return new PiecewiseIntervalPolynomialCurveElement(polynomialCurve, cutPoints);
        }
 public NewtonPolynomialCurveInterpolatedData(PolynomialCurveParam curveParam)
 {
     this.pointList = curveParam.PointList;
     this.newtonCurve = new NewtonIntervalPolynomialCurveElement(pointList);
 }
Ejemplo n.º 5
0
 public void DrawPolynomialCurve(string curveName, int polynomialType)
 {
     BaseDataPointList pointList = this.basePoints;
     PolynomialCurveParam curveParam = new PolynomialCurveParam(pointList.SortedPointList, (PolynomialCurveType)polynomialType);
     PolynomialCurve curve = new PolynomialCurve(curveParam);
     DrawLines(curveName, curve.sampleCurvePoints());
 }