public ParametricCubicSplineInterpolationInterpolatedData(ParametricCubicSplineInterpolationCurveParam curveParam)
 {
     this.curveParam = curveParam;
     PiecewiseIntervalPolynomialCurveElement xCurve = GenerateCurve(curveParam.XParam);
     PiecewiseIntervalPolynomialCurveElement yCurve = GenerateCurve(curveParam.YParam);
     curve = new ParametricCubicSplineInterpolationCurveElement(xCurve, yCurve);
 }
        private List<DataPoint> sampleAParametricCurveWithDenserBorder(ParametricCubicSplineInterpolationCurveElement curve, int maxPointCount)
        {
            if (maxPointCount < 2)
                throw new ArgumentOutOfRangeException("maxPointCount", "The desired point count to sample a curve should be bigger than 1.");
            double normalStepSize = 0.001, borderStepSize = 0.0005;
            int step, stage = 1;
            if (curve.Interval.Length > 0.2)
            {
                stage = 1;
                if (curve.Interval.Length.AccurateValue > 0.001 * maxPointCount)
                {
                    normalStepSize = (curve.Interval.Length.AccurateValue - 0.2) / maxPointCount;
                    step = maxPointCount + 400;
                }
                else
                {
                    step = (int)(curve.Interval.Length.AccurateValue * 1000) + 200;
                }
            }
            else
            {
                stage = 3;
                step = Convert.ToInt32(curve.Interval.Length.AccurateValue * 2000);
            }

            DoubleExtension parametricValue = curve.Interval.LeftBorder;
            List<DataPoint> pts = new List<DataPoint>();
            while (parametricValue < curve.Interval.RightBorder)
            {
                pts.Add(curve.calculatePoint(parametricValue));
                switch (stage)
                {
                    case 1:
                        if (curve.Interval.RightBorder - parametricValue <= 0.1)
                        {
                            stage = 3;
                        }
                        else if (parametricValue - curve.Interval.LeftBorder >= 0.1)
                        {
                            stage = 2;
                            parametricValue += normalStepSize;
                            break;
                        }
                        parametricValue += borderStepSize;
                        break;
                    case 2:
                        if (curve.Interval.RightBorder - parametricValue <= 0.1)
                        {
                            stage = 3;
                            parametricValue += borderStepSize;
                            break;
                        }
                        parametricValue += normalStepSize;
                        break;
                    case 3:
                        parametricValue += borderStepSize;
                        break;
                }
            }
            return pts;
        }