Background of the Invention
The present invention relates to a line-figure processor, and more particularly to an apparatus which generates a dot pattern forming a line segment from the coordinates of the starting point and the terminating point of the line segment.
In conventional line-figure processors, a dot pattern for a line segment extending between a given starting point and a given terminating point is produced from the coordinates of these points by means of interpolation. A typical method of the interpolation is Bresenham's algorithm, a detail of which is disclosed in "Algorithm for Computer Control of a Digital Plotter" (Bresenham, J. E., IBM System Journal, vol. 4, No 1, pp. 25-30, (1965).
The flow chart of FIG. 5 illustrates an outline of Bresenham's algorithm for 0 to 45 degrees of an angle between a given line segment and X axis. Let the coordinates of the starting and terminating points are (X.sub.o, Y.sub.0) and (X.sub.a, Y.sub.b), respectively. At the beginning, the differences in X and Y coordinates between the starting point and the terminating point, namely, a=.vertline.X.sub.a -X.sub.0 .vertline. and b=.vertline.Y.sub.b -Y.sub.0 .vertline., are calculated to supply a and b thereof to the first discriminant e.sub.1 =2b-a. Then, setting the value of K equal to 1, the coordinates of the first interpolating point (X.sub.1, Y.sub.1) are calculated as indicated in the flow chart of FIG. 5. In this calculation, when e.sub.1 >0, a step 51 is selected and when e.sub.1 <0, a step 52 is selected. In case the step 51 is selected, the coordinates of the first interpolating point and the second discriminant to be used in the next calculation are
respectively, and in case the step 52 is selected, the corresponding values are
respectively. The coordinates of successive interpolating points are calculated sequentially by repeating a similar calculation. In case the angle between the given line segment and X axis is out of 0 to 45 degree range, the generating of the dot pattern is essentially the same as aforementioned.
It can be pointed out as one of drawbacks of the conventional method described above that it inherently consumes rather a long processing time. However, the overall speed of line figure processing will be improved significantly if dot patterns for horizontal and vertical line segments, which appear very frequently in most practical cases, are generated more quickly.
Summary of the Invention
An object of the present invention is to accelerate the generation of a dot pattern for a line segment parallel with a coordinate axis, such as a vertical or a horizontal line segment, thereby improving the overall speed of a line-figure processor.
The line-figure processor of the present invention comprises a comparator which compares values of a first coordinate component (X coordinate component, for instance) of starting point coordinates and terminating point coordinates, a data modifying circuit which is started when the first coordinate component values coincide with each other and recursively modifies a value of a second oordinate component (Y coordinate component, for instance) of the starting point coordinates by a unit value ("1", for instance) up to a value of the second coordinate component of the terminating point coordinates, a coordinates producing circuit which produces interpolating coordinates data by combining one of the first coordinate component values with the successive values obtained from the data modifying circuit, and a general-purpose interpolator to be started in case the first coordinate components are not equal to each other.
If a specified line segment is parallel with one of the coordinate axis (vertical, for instance), the first coordinate component values of both the starting point and the terminating point must coincide with each other. When the comparator detects the coincidence, the data modifying circuits starts to modify the value of the other coordinate component (Y coordinate, for instance) by the unit value recursively up to the terminating point value. Consequently, a series of coordinate component values (for instance, Y.sub.0, Y.sub.0 +1, . . . , Y.sub.b) from the starting point to the terminating point are sequentially produced along the corresponding axis. These coordinate component values are combined with one of the coordinate component values which were detected to be coincident with each other to form a series of coordinates (for instance, (X.sub.0, Y.sub.0), (X.sub.0, Y.sub.0 +1), . . . , (X.sub.0, Y.sub.b)) in which one of the component remains at a constant value while the other component changes its value by the unit value. Thus, the positions of successive dots forming a line segment extending from the starting point to the terminating point in parallel with a coordinate axis (a vertical line segment, for instance) are defined by the series of coordinates described above.
The above-described processing is very simple and requires a much shorter time than the conventional general purpose interpolation, such as the Bresenham's algorithm, and only the line segments not parallel with either coordinate axis are processed by such a general- purpose interpolation. As a result, the dot patterns for the vertical and horizontal line segments which are prevailing in the practical line-figures, are produced at a remarkably faster speed, and therefore the overall processing time of the line-figure processor is improved significantly.
Other objects, features and advantages of this invention will become apparent from the following detailed description in conjunction with the accompanying drawings.
Brief Description of the Drawings
FIG. 1 is a block depicting a line-figure processor including an interpolating apparatus embodying the present invention;
FIG. 2 is a block diagram of a dot pattern generator including an interpolating apparatus embodying the present invention;
FIG. 3 illustrates an example of the dot pattern for a vertical line segment produced by the interpolating apparatus shown in FIG. 2;
FIG. 4 is a circuit diagram of a logic circuit to control the direction of counting used in another embodiment of the present invention; and
FIG. 5 is a flow chart to show an outline of the Bresenham's algorithm as a prior art.
Detailed Description of the Preferred Embodiment
FIG. 1 depicts an outline of a line-figure processing system including an embodiment of this invention. An upper-level processor 210 supplies a series of coordinates data which define a line figure which should be outputted to a line-figure processor 220. A dot pattern generator 221 in the line-figure processor 220 calculates the value 240 of each dot and the address 250 thereof from the coordinates data, and stores the calculated value of each dot in a corresponding storage location in a full dot memory 222. The full dot memory 222 has a plurality of storage locations corresponding respectively to all the dot positions on the output page. The contents of these storage locations are read out to an output equipment 230 (printer, display, etc.) sequentially in synchronism with the scanning therein. Alternatively, the output of the dot pattern generator 221 may be supplied to a plotter via an appropriate buffer, if desired.
FIG. 2 shows the dot pattern generator 221 with an interpolating apparatus which embodies the present invention. The coordinates data of a starting point X.sub.0, Y.sub.0 and of a terminating point X.sub.a, Y.sub.b supplied by the upperlevel processor 210 are stored in a starting point X coordinate registers 301, a starting point Y coordinate register 302, a terminating point X coordinate register 303, and a terminating point Y coordinate register 304, respectively. An X coordinate comparator 305 compares X.sub.0 with X.sub.a, and produces an X coordinate coincidence signal 306 when X.sub.0 equals X.sub.a. Similarly, a Y coordinate comparator 307 compares Y.sub.0 with Y.sub.b, and produces a Y coordinate coincidence signal 308 when Y.sub.0 equals Y.sub.b. The signal 306 implies that a vertical line segment is specified, and the signal 308 implies that a horizontal line segment is specified.
A controller 309 operates in response to the X coordinate coincidence signal 307 and the Y coordinate coincidence signal 308, and controls selectors 311 and 312 by means of a selection signal 310 and also controls selectors 314 and 315 by means of a selection signal 313. In case the X coordinate coincidence signal 306 is produced, that is, the line segment is vertical, the selectors are controlled so that the selector 311 selects terminating point Y coordinate data 316, the selector 312 selects starting point Y coordinate data 317, the selector 314 selects starting point X coordinate data 318, and the selector 315 selects an output 320 of a coordinate counter 319. On the other hand, in case the Y coordinate coincidence signal 308 is produced, that is, the line segment is horizontal, the selector 311 selects terminating point X coordinate data 321, the selector 312 selects the staring point X coordinate data 318, the selector 314 selects the output 320 of the coordinate counter 319, and the selector 315 selects the starting point Y coordinate data 317. In case neither the X coordinate coincidence signal 306 nor the Y coordinate coincidence signal 308 is produced, the controller 309 suppresses the selectors 311 and 312 and starts a general-purpose interpolator 322. At the same time, the controller 309 controls the selectors 314 and 315 to select an X coordinate output 323 and a Y coordinate output 324, respectively, from the general-purpose interpolator 322. The general purpose interpolator 322 may be a conventional interpolator adopting, for example, the Bresenham's algorithm mentioned previously.
A comparator 325 compares either the terminating point X coordinate data 321 or the terminating point Y coordinate data 316 as selected by the selector 311 with the output 320 of the coordinate counter 319, and sends a coincidence signal 326 to the controller 309 in case the coincidence thereof is obtained. The counter 319 receives in a register 327 either the starting point X coordinate data 318 or the starting point Y coordinate data 317 as selected by the selector 312, and counts up the data in the register 327 in synchronism with a count-up signal train 328 from the controller 309. An address computer 329 receives the X coordinate data via the selecter 314 and the Y coordinate data via the selector 315, and computes the address 250 of a storage location corresponding thereto in the full dot memory 222 (FIG. 1). The relation between the coordinates and the addresses in the full dot memory 222 is determined previously. The dot value data 240 is supplied to the full dot memory 222 from the controller 309 in synchronism with the outputting of the address 250 from the address computer 329.
The operation of the circuit illustrated in FIG. 2 in case coordinate data specifying a vertical line segment is supplied from the upper level processor 210 will be explained hereinafter with reference to FIG. 3 which illustrates the dot pattern to be generated in this case. When the line segment is vertical, the X coordinate comparator 305 produces the X coordinate coincidence signal 306 as X.sub.a is equal to X.sub.0. Responding to the signal 306, the controller 309 selects the terminating point Y coordinate data 316 (Y.sub.b) via the selector 311, the starting point Y coordinate data 317 (Y.sub.0) via the selector 312, the starting point X coordinate data 318 (X.sub.0) via the selector 314, and the output 320 of the coordinate counter 319 via the selector 315. Y.sub.0 selected by the selector 312 is stored in the register 327 of the coordinate counter 319. So the counter output 320 is Y.sub.0 at this instant. The address computer 329 calculates a full dot memory address. corresponding to the coordinates (X.sub.0, Y.sub.0) using the starting point X coordinate data X.sub.0 via the selector 314 and the counter output Y.sub.0 via the selector 315, and sends the address signal 250 to the full dot memory 222. At the same time, the controller 309 sends value "1" as the dot value data 240 to the full dot memory 222. As a result, "1" is written in a location o the full dot memory which corresponds to the coordinates (X.sub.0, Y.sub.0).
In the next step, the controller 309 supplies the counter up signal 328 to the counter 329 to increase the content of the register 327 to Y.sub.0 +1. The address computer 329 produces the address 250 corresponding to the coordinates (X.sub.0, Y.sub.0 +1) this time, and the controller 309 produces "1" again as the dot value data 240. Consequently, "1" is written in a location corresponding to the coordinates (X.sub.0, Y.sub.0 +1) in the full dot memory.
In like manner, "1"'s are written in the full dot memory locations corresponding to a series of coordinates (X.sub.0, Y.sub.0 +2), (X.sub.0, Y.sub.0 +3), . . . , (X.sub.0, Y.sub.b), respectively, in which only the Y coordinate component is increasing. When the content of the coordinate counter 309 reaches Y.sub.b, the comparator 325 produces the coincidence signal 326, and the controller 309 completes the dot pattern generation for this particular line segment.
In case the line segment is horizontal, the Y coordinate comparator 307 produces the Y coordinate coincidence signal 308, and the selectors 311, 312, 314 and 315 change their selections. The coordinate counter 319 counts up the starting point X coordinate data X.sub.0 until value X.sub.a is reached. Using the successive output data thereof and the Y coordinate data Y.sub.o, a series of coordinates (X.sub.0, Y.sub.0), (X.sub.0 +1, Y.sub.0), . . . , (X.sub.a, Y.sub.0) with only the X coordinate value increasing are produced and "1"'s are written in the corresponding locations in the full dot memory 222.
For the embodiment described hereinbefore it is assumed that the condition Y.sub.o <Y.sub.b is always satisfied for vertical line segments and X.sub.0 <X.sub.a for horizontal line segments. If inversely, the condition Y.sub.o >Y.sub.b is satisfied for vertical line segments and X.sub.0 >X.sub.a for horizontal line segments, the coordinate counter must be changed to a down counter. For the general case where none of these conditions are satisfied, an up-down or reversible counter is adopted as the coordinate counter 319 as illustrated in FIG. 4, and the controller 309 is so arranged as to examine, when one (e.g., 305) of the coordinate comparators detects coincidence, the larger/smaller relation indicated by the other coordinate comparator (e.g., 307), and to decide the counting direction of the up-down counter depending on the relation indicated by the latter comparator.
As shown in FIG. 4, and AND gate 404 combines conjunctively the "X.sub.a =X.sub.0 " output 306 of the comparator 305 and a "Y.sub.b >Y.sub.0 " output 410 of the comparator 307, and an AND gate 402 combines conjunctively the "Y.sub.b =Y.sub.0 " output 308 of the comparator 307 and a "X.sub.a >X.sub.0 " output 408 of the comparator 305. An OR gate 405 produces a count up signal 411 by combining disjunctively the outputs of the AND gates 402 and 404. On the other hand, an AND gate 403 combines conjunctively a "X.sub.a =X.sub.0 " output 306 of the comparator 305 and a "Y.sub.b <Y.sub.0 " output 409 of the comparator 307, and an AND gate 401 combines conjuntively the "Y.sub.b =Y.sub.o " output 308 of the comparator 307 and a "X.sub.a <X.sub.0 " output 407 of the comparator 305. An OR gate 406 produces a count down signal 412 by combining disjunctively the outputs of the AND gates 401 and 403. The signals 411 and 412 control an incrementer/decrementer 413 in the up-down counter 319 to effect counting-up and counting-down, respectively.
In another modification, since all vertical line segments assure X.sub.a =X.sub.0, the interpolating coordinates for the vertical line segment can be obtained by combining X.sub.a instead of X.sub.0 with the output 320 of the counter 319. Similarly, since all horizontal line segments assure Y.sub.b =Y.sub.0, the interpolating coordinates for the horizontal line segment can be obtained by combining Y.sub.b instead of Y.sub.0 with the output 320 of the counter 319. Therefore, the X.sub.a data 321 and the Y.sub.b data 316 can be introduced instead of the X.sub.0 data 318 and the Y.sub.0 data 317, to the selector 314 and 315, respectively.