vtkCardinalSpline1D provides methods for creating a 1D cubic spline object from given parameters, and allows for the calculation of the spline value and derivative at any given point inside the spline intervals.
Methods
computeCloseCoefficients
Argument
Type
Required
Description
size
Number
Yes
work
Float32Array
Yes
x
Vector3
Yes
y
Vector3
Yes
computeOpenCoefficients
Argument
Type
Required
Description
size
Number
Yes
work
Float32Array
Yes
x
Vector3
Yes
y
Vector3
Yes
options
Object
Yes
options.leftConstraint
BoundaryCondition
Yes
options.leftValue
Number
Yes
options.rightConstraint
BoundaryCondition
Yes
options.rightValue
Number
Yes
extend
Method used to decorate a given object (publicAPI+model) with vtkCardinalSpline1D characteristics.
Argument
Type
Required
Description
publicAPI
Yes
object on which methods will be bounds (public)
model
Yes
object on which data structure will be bounds (protected)
initialValues
ICardinalSpline1DInitialValues
No
(default: {})
getValue
Argument
Type
Required
Description
intervalIndex
Number
Yes
t
Number
Yes
newInstance
Method used to create a new instance of vtkCardinalSpline1D.
/** * Method used to decorate a given object (publicAPI+model) with vtkCardinalSpline1D characteristics. * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) * @param {ICardinalSpline1DInitialValues} [initialValues] (default: {}) */ exportfunctionextend( publicAPI: object, model: object, initialValues?: ICardinalSpline1DInitialValues ): void;
/** * Method used to create a new instance of vtkCardinalSpline1D. * @param {ICardinalSpline1DInitialValues} [initialValues] for pre-setting some of its content */ exportfunctionnewInstance( initialValues?: ICardinalSpline1DInitialValues ): vtkCardinalSpline1D;
/** * vtkCardinalSpline1D provides methods for creating a 1D cubic spline object * from given parameters, and allows for the calculation of the spline value and * derivative at any given point inside the spline intervals. */ export declare constvtkCardinalSpline1D: { newInstance: typeof newInstance; extend: typeof extend; }; exportdefault vtkCardinalSpline1D;
for (let k = 1; k < N; k++) { work[k] = model.coefficients[4 * k + 0] * work[N] + model.coefficients[4 * k + 1]; }
// the column vector work now contains the first // derivative of the spline function at each joint. // compute the coefficients of the cubic between // each pair of joints. for (let k = 0; k < N; k++) { const b = x[k + 1] - x[k]; model.coefficients[4 * k + 0] = y[k]; model.coefficients[4 * k + 1] = work[k]; model.coefficients[4 * k + 2] = (3 * (y[k + 1] - y[k])) / (b * b) - (work[k + 1] + 2 * work[k]) / b; model.coefficients[4 * k + 3] = (2 * (y[k] - y[k + 1])) / (b * b * b) + (work[k + 1] + work[k]) / (b * b); }
// the coefficients of a fictitious nth cubic // are the same as the coefficients in the first interval model.coefficients[4 * N + 0] = y[N]; model.coefficients[4 * N + 1] = work[N]; model.coefficients[4 * N + 2] = model.coefficients[4 * 0 + 2]; model.coefficients[4 * N + 3] = model.coefficients[4 * 0 + 3]; };
// develop constraint at rightmost point. switch (options.rightConstraint) { caseBoundaryCondition.DERIVATIVE: // desired slope at rightmost point is rightValue model.coefficients[4 * N + 0] = 0.0; model.coefficients[4 * N + 1] = 1.0; work[N] = options.rightValue; break; caseBoundaryCondition.SECOND_DERIVATIVE: // desired second derivative at rightmost point is rightValue. model.coefficients[4 * N + 0] = 1.0; model.coefficients[4 * N + 1] = 2.0; work[N] = 3.0 * ((y[N] - y[N - 1]) / (x[N] - x[N - 1])) + 0.5 * (x[N] - x[N - 1]) * options.rightValue; break; caseBoundaryCondition.SECOND_DERIVATIVE_INTERIOR_POINT: // desired second derivative at rightmost point is // rightValue times second derivative at last interior point. model.coefficients[4 * N + 1] = 2.0; if (Math.abs(options.rightValue + 2) > VTK_EPSILON) { model.coefficients[4 * N + 0] = 4.0 * ((0.5 + options.rightValue) / (2.0 + options.rightValue)); work[N] = 6.0 * ((1.0 + options.rightValue) / (2.0 + options.rightValue)) * ((y[N] - y[size - 2]) / (x[N] - x[size - 2])); } else { model.coefficients[4 * N + 0] = 0; work[N] = 0; } break; caseBoundaryCondition.DEFAULT: default: // desired slope at rightmost point is derivative from two points model.coefficients[4 * N + 0] = 0.0; model.coefficients[4 * N + 1] = 1.0; work[N] = y[N] - y[N - 2]; break; }
// solve resulting set of equations. model.coefficients[4 * 0 + 2] /= model.coefficients[4 * 0 + 1]; work[0] /= model.coefficients[4 * N + 1]; model.coefficients[4 * N + 3] = 1;
for (let k = 1; k <= N; k++) { model.coefficients[4 * k + 1] -= model.coefficients[4 * k + 0] * model.coefficients[4 * (k - 1) + 2]; model.coefficients[4 * k + 2] /= model.coefficients[4 * k + 1]; work[k] = (work[k] - model.coefficients[4 * k + 0] * work[k - 1]) / model.coefficients[4 * k + 1]; }
for (let k = N - 1; k >= 0; k--) { work[k] -= model.coefficients[4 * k + 2] * work[k + 1]; }
// the column vector work now contains the first // derivative of the spline function at each joint. // compute the coefficients of the cubic between // each pair of joints. for (let k = 0; k < N; k++) { const b = x[k + 1] - x[k]; model.coefficients[4 * k + 0] = y[k]; model.coefficients[4 * k + 1] = work[k]; model.coefficients[4 * k + 2] = (3 * (y[k + 1] - y[k])) / (b * b) - (work[k + 1] + 2 * work[k]) / b; model.coefficients[4 * k + 3] = (2 * (y[k] - y[k + 1])) / (b * b * b) + (work[k + 1] + work[k]) / (b * b); }
// the coefficients of a fictitious nth cubic // are the same as the coefficients in the first interval model.coefficients[4 * N + 0] = y[N]; model.coefficients[4 * N + 1] = work[N]; model.coefficients[4 * N + 2] = model.coefficients[4 * 0 + 2]; model.coefficients[4 * N + 3] = model.coefficients[4 * 0 + 3]; };