ILNumerics Ultimate VS

Interpolationsplinepath Method (InArrayDouble, InArrayDouble, InArrayDouble, InArrayDouble, Int32)

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Create interpolated values for the path through points given by X in R^n.

[ILNumerics Interpolation Toolbox]

Namespace:  ILNumerics.Toolboxes
Assembly:  ILNumerics.Toolboxes.Interpolation (in ILNumerics.Toolboxes.Interpolation.dll) Version: 5.5.0.0 (5.5.7503.3146)
Syntax

public static RetArray<double> splinepath(
	InArray<double> X,
	InArray<double> Xn = null,
	InArray<double> lbDeriv = null,
	InArray<double> ubDeriv = null,
	int resolution = 20
)

Parameters

X
Type: ILNumericsInArrayDouble
Matrix with points in columns. Any dimensionality (number of rows) is accepted.
Xn (Optional)
Type: ILNumericsInArrayDouble
[Optional] fractional positions to evaluate the spline for. Default (null): create [resolution] times as many intermediate points as given in X.
lbDeriv (Optional)
Type: ILNumericsInArrayDouble
[Optional] start boundary condition. Default: null (not-a-knot spline)
ubDeriv (Optional)
Type: ILNumericsInArrayDouble
[Optional] end boundary condition. Default: null (not-a-knot spline)
resolution (Optional)
Type: SystemInt32
[Optional] resolution factor for new query points to produce, times number of original values in X. Default is 20.

Return Value

Type: RetArrayDouble
Matrix with smoothed path through points defined by X. Number of rows: X.S[0], number of columns: Xn.Length
Remarks

splinepath(InArrayDouble, InArrayDouble, InArrayDouble, InArrayDouble, Int32) creates a smooth path connecting the points defined by the columns of X. Cubic spline interpolation is used to create intermediate points within individual seqments between the original points. The matrix returned can be directly used for rendering purposes.

X defines the original points as columns of the input matrix. The points are defined in R^n: any number of rows are allowed. Typically, X defines points in 2D or 3D space, resulting in a path (curve) in 2D or 3D (hypercurve). However, higher dimensionalities are supported as well.

The parameter Xn allows to control the number and position of intermediate points. The function expects a vector with values in range 0...1. Position 0 corresponds to the beginning of the path (first column of X). 1 corresponds to the end of the path at the last point in X. Values outside of that range cause extrapolated values to be computed and returned. If Xn is null (default) the number and positions of intermediate values are determined automatically. In this case, m intermediate equally spaced values are created along the path, where m = 20 x X.S[1], the number of original seqments given in X.

The parameters lbDeriv and ubDeriv are used to specify the 1st order derivative at the lower and upper bound (start and end of the curve). Leaving these parameters undefined (null) creates a not-a-knot cubic spline: the slope of the path at the end point is derived from the slope of the surrounding samples (3rd derivative = 0). If values are given for either lbDeriv and/or ubDeriv the corresponding end of the path will be computed as having that value as first derivative (slope).

Support for NaN values: spline interpolation performs interpolation by taking all values of X into account. What enables best smoothness properties on the other hand implies that any NaN value in X populate to all elements of the output. Therefore, one must ensure that no NaN values exist in X. Use cubic polynomial interpolation in interpn(InArrayDouble, InCell, InCell, InterpolationMethod) for an alternative on data with NaN values.

[ILNumerics Interpolation Toolbox]

Examples

Creates and plots a smooth path through 21 random data points. Use this example in a Windows Forms Application project.

private void ilPanel1_Load(object sender, EventArgs e) {
            // create 21 random points in 3d space
            Array</*!HC:inArr1*/ double> Points = rand(3, 21);

            // setup the plot cube ...
            ilPanel1.Scene.Add(new PlotCube(twoDMode: false) {
            // ... render original points as markers (line color: "empty" hides the line of the line plot)
            new LinePlot(tosingle(Points), lineColor: Color.Empty, markerStyle: MarkerStyle.Dot)
            });

            // setup labels next to the points
            for (int i = 0; i < Points.S[1]; i++) {
            // position for the label
            Vector3 pos = new Vector3(Points.GetValue(0,i), Points.GetValue(1,i), Points.GetValue(2,i));
            // add new label
            ilPanel1.Scene.First<PlotCube>().Add(
            new Label(i.ToString() + " ") {
            Position = pos,
            // create some margin
            Anchor = new PointF(1.5f,.5f)
            });
            }
            // generate spline interpolated values for a smoothed path through the points
            Array</*!HC:inArr1*/ double> spl = spline(Points);
            // draw the path as regular line plot
            ilPanel1.Scene.First<PlotCube>().Add(new LinePlot(tosingle(spl)));
            }
See Also

Reference

InterpolationInternal.spline(InArrayDouble, NullableDouble, InArrayDouble, InArrayDouble, InArrayDouble, InArrayDouble)
InterpolationInternal.splinen(InArraySingle, NullableSingle, InCell, InCell)
InterpolationInternal.interp1(InArrayDouble, NullableDouble, InArrayDouble, InArrayDouble, Int32, InterpolationMethod)
InterpolationInternal.interp2(InArrayDouble, NullableDouble, InArrayDouble, InArrayDouble, InArrayDouble, InArrayDouble, Int32, InterpolationMethod)
InterpolationInternal.interpn(InArrayDouble, NullableDouble, InCell, InCell, InterpolationMethod)