Detailed Contents
Introduction
Command Line
File Format
Plot Instructions
Expressions
Curve Fitting
Three-Dimensional Plots
PostScript Files
Appendix: Line Styles
Index
In addition to the two-dimensional plots covered by the examples in the previous sections, DigiPlot is able to produce a range of relatively simple three-dimensional plots with, in some cases, hidden line removal. As with the two-dimensional plots, we shall discuss the three-dimensional plotting by way of a number of simple examples. We shall consider first a three-dimensional surface plot. Suppose the following Fortran program is run to produce a data file DROP.DAT describing an axisymmetric, spatially decaying wave field:
PROGRAM Drop
INTEGER*2 i,j,n
REAL*4 x,y,z,r
OPEN(10,file='DROP.DAT',form='formatted',status='unknown')
WRITE(6,*)'n ?'
READ(5,*)n
DO i=0,n-1
x = 2.0*FLOAT(i-n/2)/FLOAT(n)
DO j=0,n-1
y = 2.0*FLOAT(j-n/2)/FLOAT(n)
r = SQRT(x*x + y*y)
z = EXP(-4.0*r)*COS(20.0*r)
WRITE(10,100)x,y,z
ENDDO
ENDDO
CLOSE(10)
100 FORMAT(3(f10.4,1x))
END
If this program is run with the value of n input as 64, then the surface to be plotted
![]() |
is recorded in DROP.DAT
as 4096 (=64*64) lines of data, each containing three columns
arranged as x,y,z.
The three coordinates all lie in the range -1 to 1. We can plot
this data using the following simple plot file:
# Plot the DROP.DAT file as a 3D C3 -1 1 -1 1 -1 1 -30 20 5.0 X [1 Y [2 Z [3 I 128 R3 64 64 3 DROP.DAT |
The C3 plot instruction sets up the coordinate system. The first three pairs of numbers set the limits for the x, y and z coordinates (which all range from -1 to 1 in this example). The region is viewed such that the x axis is oriented 30 degrees below the horizontal, and the y axis 20 degrees above the horizontal. The final value on the C3 line controls how perspective is included in the plot. The value (5.0) given indicates that the observer is positioned five units from the coordinate origin. The X, Y and Z instructions specify that the x, y and z data come from the first, second and third columns respectively. As before the I instruction dictates the colour to be used for the plotting. Finally, the R3 instruction informs DigiPlot that there are 64 data points in the x direction and 64 in the y direction. The value 3 indicates that a wire frame is to be produced with hidden line removal. The other options available are stated in section 4 . It is worth noting that options 5 and 6 often produce more spectacular looking results. Both these options colour the surface with an intensity governed by the orientation of the surface to some arbitrary light source to synthesise the effects of illumination. The options differ in that with 5 the wire frame is drawn with the intensity set by the I instruction, while option 6 does not include a wire frame.
Our second example shows the use of some of the other
three-dimensional plotting instructions. Here we attempt to illustrate
a Perspex box with a metal barrier half way up the box.
################################################################## # Draw Box with Barrier ################################################################## C3 -270 130 -200 200 -200 200 -50 30 4 X [1 Y [2 Z [3 ################################################################## # Draw Back and bottom of box ################################################################## I 255 N3 L3 # Back and bottom -100 -200 -250 100 -200 -250 100 200 -250 -100 200 -250 -100 -200 -250 # Edges N3 -100 -200 -250 -100 -200 250 N3 -100 200 -250 -100 200 250 ################################################################## # Draw the plate ################################################################## # Base I 32 PL3 4 160 -95 -400 0 95 -400 0 95 50 0 -95 50 0 ################################################################## # Slot in box ################################################################## # In end of box L3 N3 I 255 -95 -200 2 95 -200 2 95 -200 -2 # Box interior I 96 N3 95 -195 -2 95 195 -2 -95 195 -2 -95 50 -2 # Top N3 -95 -195 2 95 -195 2 95 195 2 -95 195 2 -95 -195 2 # Sides N3 95 195 -2 95 195 2 N3 -95 195 -2 -95 195 2 ################################################################## # Top and front of box ################################################################## I 255 L3 N3 -100 -200 250 100 -200 250 100 200 250 -100 200 250 -100 -200 250 N3 100 -200 -250 100 -200 250 N3 100 200 -250 100 200 250 |
After setting up the coordinate system with the C3 instruction, we have specified the x, y and z coordinates as residing in the first three columns of data. The L3 instruction is used to specified that lines should be drawn three-dimensions as the edges of the box. The N3 instruction indicates where a new series of lines should be started (this is equivalent to lifting your pen from the paper).
To draw the barrier we use the polygon plotting ability
of DigiPlot. The PL3
instruction indicates that polygons are to be plotted in three-dimensions,
the two pieces of data on the line indicating that the polygon
has four vertices and should be filled with an intensity 196.
The four data lines immediately following this instruction are
then used to specify the coordinates of the vertices of the polygon.
The edges of the polygon are drawn with the intensity set by the
I instruction after the polygon has
been filled.
Goto next document (PostScript)
DigImage documentation page
DigImage home page
Stuart Dalziel's home page