Point2Bvr[] ptsPt2 = new Point2Bvr[numPts];
2 more knots than control points since a cubic |
NumberBvr[] knotsNum = new NumberBvr[numPts + 2];
Point2Bvr initPt2; initial position of a draggable
DraggableButton draggable; holder of a draggable point
ImageBvr ptsImg = emptyImage; the accumulated image
construct the control points and the knot vector |
for (int i = 0; i < numPts; i++) {
initPt2 = point2(add(initX,mul(toBvr(i),incX)), toBvr(initY));
draggable = new DraggableButton(initPt2);
ptsPt2[i] = draggable.getPointBvr();
ptsImg = overlay(ptsImg, draggable.getImageBvr());
knotsNum[i] = toBvr(i-2); we want the first 3 knots to be 0, see next
}
Set first and last two knots to achieve multiplicity 3,
this makes the spline pass through the first and last control points. |
knotsNum[0] = knotsNum[1] = toBvr(0);
knotsNum[numPts] = knotsNum[numPts + 1] = knotsNum[numPts - 1];
generate images of the spline and its control polygon |
Path2Bvr cubicCurvePath = cubicBSplinePath(ptsPt2, knotsNum);
Path2Bvr controlPolyPath = polyline(ptsPt2);
LineStyleBvr lLnS = defaultLineStyle.width(toBvr(0.5*mm));
ImageBvr cubicCurveImg = cubicCurvePath.draw(lLnS.color(green));
ImageBvr controlPolyImg = controlPolyPath.draw(lLnS.color(white));
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.