Object first = extraPoints.get(0);
extraPoints.remove(0);
extraPoints.add(first);
GeneralPath path = new GeneralPath();
int m = extraPoints.size();
ensureBases(m);
segments.clear();
// Iterate over segments:
for (int i=3; i<m-1; i++) {
Polynomial xNum = new Polynomial(0);
Polynomial yNum = new Polynomial(0);
Polynomial xDen = new Polynomial(0);
Polynomial yDen = new Polynomial(0);
// Iterate over control points:
for (int j=0; j<m; j++) {
Point2D p = (Point2D) extraPoints.get(j);
BasisFunction basis = (BasisFunction) Bases.get(j);
double px = p.getX();
double py = p.getY();
Polynomial xSegNum = basis.getSegment(i).multiply(px * Weight);
Polynomial ySegNum = basis.getSegment(i).multiply(py * Weight);
Polynomial xSegDen = basis.getSegment(i).multiply(Weight);
Polynomial ySegDen = basis.getSegment(i).multiply(Weight);
xNum = xNum.add(xSegNum);
yNum = yNum.add(ySegNum);
xDen = xDen.add(xSegDen);
yDen = yDen.add(ySegDen);
}
Shape curve = Polynomial.createRationalShape(
xNum, xDen, yNum, yDen, i, i + 1, .1
);
segments.add(curve);
path.append(curve, true);
}
path.closePath();
shape = path;
}