public ParametricCubicSplineInterpolationCurveElement(PiecewiseIntervalPolynomialCurveElement xCurve, PiecewiseIntervalPolynomialCurveElement yCurve) { if (!xCurve.Interval.Equals(yCurve.Interval)) throw new ArgumentException("The X and Y piecewise curve should have the same intervals."); this.interval = xCurve.Interval; this.xCurve = xCurve; this.yCurve = yCurve; }
public CubicSplineInterpolationInterpolatedData(CubicSplineInterpolationCurveParam curveParam) { this.curveParam = curveParam; this.curve = GenerateCurve(curveParam); }
private List<DataPoint> sampleAPolynomialCurveWithDenserBorder(PiecewiseIntervalPolynomialCurveElement 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 xValue = curve.Interval.LeftBorder; List<DataPoint> pts = new List<DataPoint>(); while (xValue < curve.Interval.RightBorder) { pts.Add(new DataPoint(xValue, curve.calculate(xValue))); switch (stage) { case 1: if (curve.Interval.RightBorder - xValue <= 0.1) { stage = 3; } else if (xValue - curve.Interval.LeftBorder >= 0.1) { stage = 2; xValue += normalStepSize; break; } xValue += borderStepSize; break; case 2: if (curve.Interval.RightBorder - xValue <= 0.1) { stage = 3; xValue += borderStepSize; break; } xValue += normalStepSize; break; case 3: xValue += borderStepSize; break; } } return pts; }