int span = uKnots.findSpan(uk[i]);
double[] tmp = uKnots.basisFunctions(span, uk[i]);
System.arraycopy(tmp, 0, A, i * n + span - degree, tmp.length);
}
final GMatrix a = new GMatrix(n, n, A);
final GVector perm = new GVector(n);
final GMatrix lu = new GMatrix(n, n);
a.computeLUD(lu, perm);
final Vec4D[] cps = new Vec4D[n];
for (int i = 0; i < cps.length; i++) {
cps[i] = new Vec4D(0, 0, 0, 1);
}
// x-ccordinate
final GVector b = new GVector(n);
for (int j = 0; j < n; j++) {
b.setElement(j, points[j].x);
}
final GVector sol = new GVector(n);
sol.backSolveLUD(lu, b, perm);
for (int j = 0; j < n; j++) {
cps[j].x = (float) sol.get(j);
}
// y-ccordinate
for (int j = 0; j < n; j++) {
b.setElement(j, points[j].y);
}
sol.zero();
sol.backSolveLUD(lu, b, perm);
for (int j = 0; j < n; j++) {
cps[j].y = (float) sol.get(j);
}
// z-ccordinate
for (int j = 0; j < n; j++) {
b.setElement(j, points[j].z);
}
sol.zero();
sol.backSolveLUD(lu, b, perm);
for (int j = 0; j < n; j++) {
cps[j].z = (float) sol.get(j);
}
return new BasicNurbsCurve(cps, uKnots);
} catch (SingularMatrixException ex) {
throw new InterpolationException(ex);
}