$a page=10.3";top=0.5";bottom=0.5";line=6.25";left=0.8" $a nls=1.4;just=1;pgap=0.3";sgap=0.2" $a tab=0.5",1",1.5",2",2.5",3",3.5",4",4.5",5",5.5",6" $f10=TimesR10 $f20=TimesB10 $f30=TimesI10 $f22=TimesB12 $f24=TimesB14 $10 $a pageno=1 $l5m $24(B-Spline Demonstrator by Jeremy Gibbons) $22(March 1987) $b4 $b2$v5$22(Introduction) $p1 This program is an interactive $30(B-spline) editor; it demonstrates the use of quadratic B-splines for drawing curves. The curve can be $30(open) or $30(closed). Multiple (double) knots can be placed in arbitrary positions. There is no restriction on the order of adding, changing and removing $30(control points) and of making $30(multiple knots). In addition, the $30(convex hull) of the curve can be drawn. $p0 The source and object files are $20(JG:Curve) and $20(JG:Curve.mob), respectively, on filestore C. $b2$v5$22(Commands) $p1 Interaction is entirely mouse driven. As well as the area of the screen used to display the curve, there is a menu giving the available commands, and a display of the $30(knot set) (see description of how to make multiple knots). To select a command, the cursor is placed on it, and any button is clicked. $p0 To $30(change) (move) control points, the user moves the cursor over the point in question, presses the left mouse button, moves the point to the desired position, and then releases the mouse button. The control polygon and the curve are continually redrawn to reflect the position of the changing point. Several points can be changed; clicking the right mouse button returns the cursor to the menu. $p0 Points are $30(added) between two consecutive control points. Clicking the left button moves a highlight round edges of the control polygon. Pressing the middle button places a new control point in the middle of this edge; the point can be repositioned as when changing points, above, until the button is released. Again, this can be repeated as often as desired; clicking the right button returns the cursor to the menu. The knot set is updated accordingly (adding a single knot). $p0 To $30(remove) a point, the cursor is positioned over it and the left button clicked. The point is removed, and the knot set is updated. If there was a kink in the curve at that point, the double knot is made single; if not, a knot is removed. Note that this may remove a kink elsewhere (close by) in the curve. If every knot is a double knot, there will only be a kink at every other control point. Removing a control point at which there is no kink necessarily makes a double knot single. $p0 Care is taken not to remove the triple knots at the ends of an open curve, otherwise the curve wouldn't terminate properly. There is a minimum of three control points, whether the curve is open or closed. Again, several points can be removed before returning to the menu. $p0 The knot set is displayed on a scale from 0 to N, the maximum knot value; at each point on the scale, a dot is drawn for each of the knots at that value. Thus, at the ends of an open curve (0 and N) there are three dots; at double knots, two, and at single knots, one dot. The cursor is moved up and down this scale to choose a point to $30(make multiple). The left button is clicked on the required knot; if it isn't already multiple, it is made so, and an extra control point is added at that place on the curve (the kink in the curve will be at this new control point). Clicking the right button returns to the menu. Multiple knots are made single again by removing the control point at the kink in the curve. $p0 $30(Show convex hull) is a toggle; selecting it displays the convex hull (and leaves the cursor on the menu). The command gets replaced with the comand $30(Hide convex hull). Clicking on this removes the convex hull. While it is displayed, the convex hull moves with the curve. $p0 $30(Initialise open curve) and $30(Initialise closed curve) set the control polygon to a square. If the curve is open, it is a U-shape, otherwise it is circular(ish). $p0 $30(Quit) allows a clean exit from the program. $b2$v5$22(Missing Features and Problems) $p1 The curve is drawn using fixed point (ie, integers shifted up 8 places) arithmetic for speed. I tried further optimisation in the form of a difference technique to avoid the multiplications, but this seemed to make no difference whatsoever. $p0 Mouse debouncing is primitive. It consists of reading the mouse buttons, then waiting for a while (fifty times round an empty loop). $p0 When moving control points, a section of the curve gets erased and redrawn. This occasionally erases other bits of the curve; this is cured by redrawing the entire curve when the moved point is put down. With better economy of planes (there is only one free plane at the moment), moving sections could be drawn on different planes, avoiding this problem. $p0 When a point is selected, the first point near (within nine pixels of) the cursor is found. This occasionally means that a previous point is picked up instead of the intended one. This can be cured by moving the offending (previous) point, moving the desired point out from underneath it, then replacing the first point. $p0 There is a bit of flicker when redrawing the curve while moving a point. This is especially bad at the ends of the curve; the time taken to redraw is perhaps close to (a multiple of) the time taken to refresh the display, resulting in a "standing wave" effect. The flicker could be cured by double buffering - drawing alternate images in different halves of the framestore. $p0 None of these problems reduces the programs's ability to perform its task, which is to demonstrate quadratic B-spline curves. $e