/// <summary> /// Interpolates at indices which are obtained using <paramref name="samplingStep"/>. /// <para>Distances between points do not have to be equal because control points may not be equally distributed.</para> /// <para>For equally distributed points please use: <seealso cref="GetEqualyDistributedPointIndices"/>.</para> /// </summary> /// <param name="controlPoints">Control points of the spline.</param> /// <param name="tension">Tension of the spline.</param> /// <param name="samplingStep">Index increase factor.</param> /// <returns>Interpolated points.</returns> public static IEnumerable <PointF> Interpolate(IList <PointF> controlPoints, float tension, float samplingStep = 0.3f) { //interpolate points for (float i = MIN_INDEX; i < (controlPoints.Count - 1 - MAX_INDEX_OFFSET); i += samplingStep) { var pt = CardinalSpline.InterpolateAt(controlPoints, tension, i); yield return(pt); } }
/// <summary> /// Interpolates points and defined indices. /// </summary> /// <param name="controlPoints">Control points of the spline.</param> /// <param name="tension">Tension of the spline.</param> /// <param name="indices">Indices where to interpolate values.</param> /// <returns>Interpolated points.</returns> public static IEnumerable <PointF> InterpolateAt(IList <PointF> controlPoints, float tension, IEnumerable <float> indices) { return(indices.Select(x => CardinalSpline.InterpolateAt(controlPoints, tension, x))); }