Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 9, NO. 12 / DECEMBER 1983 / PAGE 235

Plotter tutorial. (part 1) David H. Ahl.

PLOTTER TUTORIAL

Part 1

Did you get a plotter to make bar charts for business reports? Or are you using a plotter for architectural drawings? Or did you decide it would just make a nice addition to your computer system?

No matter what your reason for getting a plotter, at some point you will want to use it as an artistic tool. In this series of tutorials, we will look at the basic principles of plotting as we work our way toward doing some wild and wonderful drawings.

Mathematics--The Basis of Plotting

Plotting is not a free-form process. A graphics entry tablet is an electronic analog to a canvas, paint, and brushes. On the other hand, a plotter is analogous to a mechanical drawing table, ink, and drafting instruments--but not quite, as everything must be defined in mathematical coordinates before a plotter can do its job.

The mathematics for plotting need not be intimidating. All that is needed is arithmetic, simple geometry, and sometimes a bit of algebra. Indeed, most modern plotters take care of a great deal of the mathematics internally.

Our Plotter--And Yours

For this first tutorial, we have chosen to use a Houston Instrument DMP-29 plotter so our scaling and commands will correspond to that unit. However, everything in this article can be applied to any plotter--Strobe, Mannesmann Tally, Hewlett Packard, et al.

The DMP-29 plotter can plot in increments (step sizes) of 0.001 , 0.005 , and 0.1 mm. We chose to use the largest step size (0.005 ). This means that there are 200 steps per inch and that the maximum plotting dimensions of 10 X 15 correspond to 2000 steps and 3000 steps. Thus, our active plotting area has xY coordinates 0,0 in the lower left and 3000,2000 in the upper right (see Figure 1). You should prepare a similar diagram for your plotter.

The DMP-29 plotter is linked to a computer via the RS-232 port. Our programs refer to the plotter as device 1, so all plotter commands are sent using a statement such as:

PRINT #1, "Stuff to plotter'

For example, to draw a border around the outside of the paper, we would give the command:

PRINT #1, "0,0 3000,0 3000,2000 0,2000 0,0'

Values in each pair of xY points are separated by a comma, while pairs of points are separated by a space. Determine how this is done on your plotter, and draw a border around the edge of a sheet of paper.

Lines In A Circle

A plot that plotter manufacturers often use to show off their plotters at a show-- don't ask us why--is a circle with lines connecting points on the circumference. A circle can be divided into any reasonable number of increments. We chose 16 points to start.

We arbitrarily numbered the 16 points on the circumference starting at zero degrees and proceeding counter clockwise. To use these points in a plot, we need to know the x and y value of each one. From algebra, we know that the equation describing a circle is x2+y2=r2. However, that isn't a great deal of help. Much more useful in this case is remembering that angular points can be defined with the sine and cosine functions.

Thus if we want the x and y value of point 3, we must know the angle between points 1 and 3 (45 degrees). Then, the x value of point 3 is the sine of 45 (0.7071) and the y value is the cosine of 45. These values are for a circle of radius 1 and must be nultiplied by the appropriate scaling factor. We multiplied by 800 so our final plot would be 1600 units (8 ) in diameter.

These values also assume that the origin (0,0) is at the center of the plot. Since this is generally not the case, you must add appropriate x and y distances from the plotter origin at the lower left. We added 1600 to our x values and 1000 to our y values.

The Basic on most computers requires the angular arguments of trig functions (sine, cosine, tangent) to be expressed in radians. We made this conversion in lines 60 and 80 (see Listing 1).

The 16 points on the circumference are defined in lines 90 and 100. From line 120 on is the plot routine to connect selected pairs of points.

Note that we defined the point pairs to be connected in the two data statements (210, 220) rather than coming up with a mathematical progression to define the point pairs.

This part of the program could be simpler, but we wanted a two-color plot. Line 130 moves the first pen to the first xY coordinate. The loop from line 140 to 170 reads successive points from the data statements and instructs the plotter to draw a line between pairs of them. Line 180 raises the first pen and gets the second one, after which the loop is repeated with the second 16 pairs of points. Line 200 instructs the pen to go to the "home' position (0,0).

The final plot is shown in Figure 3.

The Orbiter

For our next plot, we turned to a book of string art patterns, Pictures With Pins. The book was published by Arco in 1978 and it has been on the remainder shelves for the past few years. No author is credited.

We did not copy any patterns exactly from the book. Rather, we used them as a basis for similar designs which lent themselves to the plotter.

The most difficult thing about any plot is defining the points. Doing that is generally far more time-consuming and takes more lines in the program than actually drawing the plot. In that regard, the Orbiter plot was no exception.

If parts of a plot are reflected or mirror images of another part, a great deal of time can be saved by defining one section and transposing or reflecting it into another quadrant. That is what we did with the Orbiter plot.

All two-dimensional straight lines can be defined with the equation y@x+b. In the Orbiter plot, we wanted a slanted line in each quadrant. Because of they symmetry of this plot, we decided to take advantage of the capability of the plotter to redefine the origin any place on the plotting surface. We put it in the center (1500,1000). We then decided our slanted line should go from x=200, y=800 to x=1400, y=400 (see Figure 4). This led to an equation of y=-x/3+867.

We also decided that the points in the center cross should go from 0,0 to 0,144 and form 0,0 to 144,0. We arbitrarily decided to ahve 25 points along each line segment and assigned index values to all the points (see Figure 5).

Now for the tedious part--writing the program (see Listing 2). First, each xY point pair in the initial slanted line was defined (lines 80 and 90) and all of the transposed and mirror image point pairs were assigned values (lines 100 and 110).

Then all of the point pairs in the center cross were assigned values in lines 140 to 190. These were assigned in groups of 13 since the line makes a right angle at the center.

Since we chose our index values reasonably cleverly (points to be connected are in pairs such as 32, 132 and 84, 184), it was a simple matter to write the part of the program that draws the plot. The main plot is drawn in lines 220 to 240.

Line 250 gets a second color pen, and the two outside portions of the Orbiter are joined in the loops at lines 260 to 280 and 290 to 310. The final Orbiter is shown in Figure 6.

Tornado Plot

The Tornado was also inspired by pictures With Pins. In contrast to the Pictures With Pins. In contrast to the eight quarter circles to be exact.

Initially, we attempted to define just the points in one quarter of a circle and transpose them to the other seven locations. It probably could be made to work; however, four of the quarter circles kept coming out as either straight lines or with reversed curvature. Hence, we finally gave up and defined the points in an entire circle (limes 70 to 110) and then selected whichever quadrant was required (lines 120 to 210).

However, we are getting ahead of ourselves. In the Tornado, as with every plot, the first thing is to sketch out the points first and assign index values to all the point pairs (see Figure 7). We decided that each quarter circle was to be divided into 36 segments and that the radius of each one should be 375 units. Around the outside of the diagram, we noted nine of the coordinate pair values.

As with most plot programs, the tedious part is setting the values of all the point pairs. As mentioned above, this is done in Lines 120 to 210. We divided the plot into four horizontal areas, E, F, G, and H. Within each area are 73 point pairs.

The Tornado plot has two major plotting routines. The first draws the longer lines with one color between segments E and G, and F and H. The second draws the shorter lines between E and F, and G and H. The finished plot is shown in Figure 8.

Interconnected Hyperbolas

The last plot is an original one done with all straight lines, but which give the illusion of being curved. Again, we are working with a plot with maximum coordinates of 3000,2000. Index values of the coordinate point pairs are shown in Figure 9.

In this figure, the equation of one diagonal line must be defined. We wanted it to run from x=75, y=75 to x=2925, y=1925, so the equation of the line was y=.649x+26.325. Note the use of this equation in line 210 of Listing 4.

The values of the outside rectangle are assigned in lines 170 to 200, while the reflected and transposed images of the diagonal line are set in lines 210 to 240. There is nothing complex about any of these routines to set the values of point pairs except that you must keep track of the index values.

Since we did not assign the point index values very cleverly in this program, many more program lines were required to define plotter movement than in the previous programs. Of course, part of this is because there are more segments to be connected (each border point is connected to two others, and each diagonal point is connected to four others).

Program lines to instruct the plotter to draw the center portion of the plot are found in the loop from lines 410 to 460. The final program lines (470, 480) connect the four center points in an X, and line 490 instructs the pen to return to the origin. The final plot is shown in Figure 10.

Let Us See Your Plots

For future installments of this tutorial series, we would like to include reader submissions as well as our material. When sending a plot, please include a program listing (dark ribbon, single spaced), a clear description of how it was produced along with any mathematics required (typed, double spaced), and any supplemental diagrams.

Next installment: spirals and the random factor.

Table: Listing 1. Program listing for lines in circle plot.

Table: Listing 2. Program listing for Orbiter plot.

Table: Listing 3. Program listing for Tornado plot.

Table: Listing 4. Program listing for Interconnected Hyperbolas plot.

Photo: Figure 1. Plotter coordinates on DMP-29 plotter.

Photo: Figure 2. Circle is divided into 16 pieces.

Photo: Figure 3. Finished lines in circle plot.

Photo: Figure 4. Coordinates for the Orbiter plot.

Photo: Figure 5. Index values of line segments of Orbiter plot.

Photo: Figure 6. Finished Orbiter plot.

Photo: Figure 7. Coordinates and index values for the Tornado plot.

Photo: Figure 8. Finished Tornado plot.

Photo: Figure 9. Index values of line segments for Interconnected Hyperbolas plot.

Photo: Figure 10. Finished Interconnected Hyperbolas plot.