/// <summary> /// Factory method to create the required implementation of the interpolation algorithm /// </summary> /// <param name="fit">interpolation algorithm type</param> /// <param name="standards">Data points to be fitted</param> /// <returns>Interpolation algorithm</returns> public static Interpolator Create(CurveFits fit, IEnumerable <DPoint> standards) { Interpolator interp = null; //ensure points are sorted in order of x values List <DPoint> standardsList = new List <DPoint>(standards); standardsList.Sort((a, b) => a.X.CompareTo(b.X)); switch (fit) { case CurveFits.Interpolate: interp = new SimpleInterpolator(standardsList); break; case CurveFits.LinearZero: interp = new BestLineThruOriginInterpolation(standardsList); break; case CurveFits.Linear: interp = new BestLineInterpolation(standardsList); break; case CurveFits.Quadratic: interp = new QuadraticInterpolator(standardsList); break; case CurveFits.QuadraticThruZero: interp = new QuadraticThruZeroInterpolator(standardsList); break; default: break; } return(interp); }
/// <summary> /// Factory method to create the required implementation of the interpolation algorithm /// </summary> /// <param name="fit">interpolation algorithm type</param> /// <param name="standards">Data points to be fitted</param> /// <returns>Interpolation algorithm</returns> public static Interpolator Create(CurveFits fit, IEnumerable<DPoint> standards) { Interpolator interp = null; //ensure points are sorted in order of x values List<DPoint> standardsList = new List<DPoint>(standards); standardsList.Sort((a, b) => a.X.CompareTo(b.X)); switch (fit) { case CurveFits.Interpolate: interp = new SimpleInterpolator(standardsList); break; case CurveFits.LinearZero: interp = new BestLineThruOriginInterpolation(standardsList); break; case CurveFits.Linear: interp = new BestLineInterpolation(standardsList); break; case CurveFits.Quadratic: interp = new QuadraticInterpolator(standardsList); break; case CurveFits.QuadraticThruZero: interp = new QuadraticThruZeroInterpolator(standardsList); break; default: break; } return interp; }