The SPLINE_P procedure performs parametric cubic spline interpolation with relaxed or clamped end conditions.

This routine is both more general and faster than the SPLINE function. One call to SPLINE_P is equivalent to two calls to SPLINE, as both the X and Y are interpolated with splines. It is suited for interpolating between randomly placed points, and the abscissa values need not be monotonic. In addition, the end conditions may be optionally specified via tangents.

This routine is written in the IDL language. Its source code can be found in the file spline_p.pro in the lib subdirectory of the IDL distribution.

Examples


The commands below show a typical use of SPLINE_P:

; Abscissas for square with a vertical diagonal:
X = [0.,1,0,-1,0]
; Ordinates:
Y = [0.,1,2,1,0]
; Interpolate with relaxed end conditions:
SPLINE_P, X, Y, XR, YR
; Show it:
PLOT, XR, YR

As above, but with setting both the beginning and end tangents:

SPLINE_P, X, Y, XR, YR, TAN0=[1,0], TAN1=[1,0]

This yields approximately 32 interpolants.

As above, but with setting the interval to 0.05, making more interpolants, closer together:

SPLINE_P, X, Y, XR, YR, TAN0=[1,0], TAN1=[1,0], INTERVAL=0.05

This yields 116 interpolants and looks close to a circle.

Syntax


SPLINE_P, X, Y, Xr, Yr [, /DOUBLE] [, INTERVAL=value] [, TAN0=[X0, Y0]]
[, TAN1=[Xn-1, Yn-1]]

Arguments


X

The abscissa vector. X should be floating-point or double-precision.

Y

The vector of ordinate values corresponding to X. Y should be floating-point or double-precision.

Neither X or Y need be monotonic.

Xr

A named variable that will contain the abscissa values of the interpolated function. If X or Y is double-precision, then the computations will be done using double-precision and a double-precision result will be returned. Otherwise, single-precision will be used.

Yr

A named variable that will contain the ordinate values of the interpolated function. If X or Y is double-precision, then the computations will be done using double-precision and a double-precision result will be returned. Otherwise, single-precision will be used.

Keywords


DOUBLE

Set this keyword to perform computations using double-precision arithmetic and to return a double-precision result.

INTERVAL

Set this keyword equal to the desired interval in XY space between interpolants. If omitted, approximately 8 interpolants per XY segment will result.

TAN0

The tangent to the spline curve at X[0], Y[0]. If omitted, the tangent is calculated to make the curvature of the result zero at the beginning. TAN0 is a two element vector, containing the X and Y components of the tangent.

TAN1

The tangent to the spline curve at X[n-1], Y[n-1]. If omitted, the tangent is calculated to make the curvature of the result zero at the end. TAN1 is a two element vector, containing the X and Y components of the tangent.

Version History


Pre-4.0

Introduced

6.1

Added DOUBLE keyword

See Also


SPL_INIT, SPLINE