Commit ab2155b9 authored by David Gobbi's avatar David Gobbi
Browse files

BUG: Fix closed vtkKochanekSpline derivatives at first/last point.

The scaling parameters for nonuniform sampling were miscomputed for
the first/last point in closed curves.  Also, the code for generating
a straight line segment for data with just two points was both
unnecessary and incorrect, it ignored the possibility of end-point
derivatives generating a curve from just the two points.

Change-Id: I5229b839d6d70ba5c44a0fbea45b82ea050d6327
parent be64234e
......@@ -217,20 +217,6 @@ void vtkKochanekSpline::Fit1D (int size, double *x, double *y,
int N; /* top point number */
int i;
if (size == 2)
{
// two points, set coefficients for a straight line
coefficients[0][3] = 0.0;
coefficients[1][3] = 0.0;
coefficients[0][2] = 0.0;
coefficients[1][2] = 0.0;
coefficients[0][1] = (y[1] - y[0]) / (x[1] - x[0]);
coefficients[1][1] = coefficients[0][1];
coefficients[0][0] = y[0];
coefficients[1][0] = y[1];
return;
}
N = size - 1;
for (i=1; i < N; i++)
......@@ -259,6 +245,9 @@ void vtkKochanekSpline::Fit1D (int size, double *x, double *y,
// Calculate the deriviatives at the end points
coefficients[0][0] = y[0];
coefficients[N][0] = y[N];
coefficients[N][1] = 0.0;
coefficients[N][2] = 0.0;
coefficients[N][3] = 0.0;
if ( this->Closed ) //the curve is continuous and closed at P0=Pn
{
......@@ -274,8 +263,8 @@ void vtkKochanekSpline::Fit1D (int size, double *x, double *y,
// adjust deriviatives for non uniform spacing between nodes
n1 = x[1] - x[0];
n0 = x[N] - x[N-1];
ds *= (2 * n1 / (n0 + n1));
dd *= (2 * n0 / (n0 + n1));
ds *= (2 * n0 / (n0 + n1));
dd *= (2 * n1 / (n0 + n1));
coefficients[0][1] = dd;
coefficients[0][2] = ds;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment