Tải bản đầy đủ
APPENDIX E.2: LINE PROFILES COMPUTER PROGRAM “GRAPH-E2”

APPENDIX E.2: LINE PROFILES COMPUTER PROGRAM “GRAPH-E2”

Tải bản đầy đủ

3-D CHARTS AND SURFACE MODELS

167

This first segment of code contains the copyright notice, and the numeric and string variables which require to be
initialized for use in the program. For memory considerations, note that the maximum number of grid points, i.e. rows
and columns is 50 each, Z(50,50).
(b) Data loading

Line numbers 100–160

See the notes for section (b) of Appendix D.2.
(c) Digital ground model data

Line numbers 200–390

This segment of code displays the maximum and minimum X, Y and Z values in the data file.
(d) Graph presentation selection

Line numbers 600–790

The user now has to choose whether to display the line profiles with or without a background grid.
(e) Set up display screen

Line numbers 1000–1080

This segment of code now sets up the screen (GOSUB 7300), titles the graph (GOSUB 7500) and draws a background
grid if required (GOSUB 7600).
(f) Line profile display

Line numbers 1500–1950

This segment of code is similar to the 3-D area chart display (Appendix E.1), but without depth enhancement to allow
up to 50 rows to be displayed.
This program also requires routines (i)–(w) with the exception of (p) and (v) from Appendix E.1. Note that routine
(1), Appendix A.11, requires an additional Line ‘7531 RETURN’ as there is no Y-axis label.
“GRAPH-E2”—BASIC program

10 REM Presentation Graphics Appendix E.2–3D Graphs
14 REM (C) Copyright P.H.Milne 1990 *** - Line Profile ***
16 REM ALL RIGHTS RESERVED
20 REM VERSION PC-1.00, 1990: *** Maximum 50,50 of Data ***
30 CLEAR
40 ON ERROR GOTO 10000
50 PCF$ = "PGSCRDSK.PGD"
60 GOSUB 8000: REM Check Screen & Disc
70 GX0 = 70: GY0 = 50: A$ = "*": DATBX = 0
80 DIM Z(50, 50), CL%(10)
90 WINDOW (0, 0) - (639, 199)
100 PC$ = "Line Profile"
110 GOSUB 8200: REM Check ID File and DATA
120 LOCATE 15, 10: PRINT "Number of Rows = "; NROW
130 LOCATE 17, 10: PRINT "Number of Columns = "; NCOL
140 LOCATE 20, 10: PRINT "Do you wish to VIEW Graph (Y/N) ";
145 A$ = INPUT$(1)

168

APPENDICES

150 IF INSTR("YNyn", A$) = 0 THEN 140
160 IF A$ = "N" OR A$ = "n" THEN 9600
200 CLS: GOSUB 9000
210 LOCATE 6, 10: PRINT "Digital Ground Model "; DFILEN$
220 LOCATE 10, 10: PRINT "X-AXIS : Min = "; XMIN
230 LOCATE 10, 40: PRINT ": Max = "; XMAX
240 LOCATE 12, 10: PRINT "Y-AXIS : Min = "; YMIN
250 LOCATE 12, 40: PRINT ": Max = "; YMAX
260 LOCATE 14, 10: PRINT "Z-AXIS : Min = "; ZMIN
270 LOCATE 14, 40: PRINT ": Max = "; ZMAX
300 ZMIN = INT(ZMIN / 10) * 10: ZMAX = (INT(ZMAX / 10) + 1) * 10
340 XTC = (XMAX − XMIN) / 10
350 TCC = XTC: GOSUB 7100
360 XTC = TCC: XM = 360
370 YTC = (ZMAX − ZMIN) / 5
380 TCC = YTC: GOSUB 7100
390 YTC = TCC: YM = 60
600 REM Continue on same screen
610 LOCATE 16, 10: PRINT "Select Graph Presentation :-"
620 LOCATE 18, 10: PRINT "<1> 3D Profile with Background Grid"
630 LOCATE 20, 10: PRINT "<2> 3D Profile only"
670 LOCATE 22, 10: PRINT "Enter Choice "; : SEL$ = INPUT$(1)
680 IF INSTR("12", SEL$) = 0 THEN 670
690 NSEL = VAL(SEL$)
700 ON NSEL GOTO 710, 720
710 HGRID = 1: DATBX = 1: GOTO 750
720 HGRID = 0: DATBX = 1: GOTO 750
750 CLS: GOSUB 9000
760 X3ND = 120 / (2 * NROW): Y3ND = 60 / (2 * NROW)
770 XCND = (360/(2 * NCOL))
780 X0F = GX0 + 10 + XCND / 2
790 GOSUB 8500
1000 GRAPH = 2: GOSUB 7300: REM Sets up Screen
1010 GOSUB 7500
1070 IF HGRID = 0 THEN 1090
1080 GOSUB 7600: REM Draw Grid
1090 CL%(1) = 4: CL%(2) = 15
1499 REM ***** Line Profile *****
1500 FOR J = NROW − 1 TO 0 STEP −1
1505 FOR CLOR = 1 TO 2
1510 X1 = (XMIN) * 36 / XTC + X0F + (2 * J) * X3ND
1520 X2 = X1: Y1 = GY0 + (2 * J) * Y3ND
1530 Y2 = (Z(J, 0) − ZMIN) * 12 / YTC + GY0 + (2 * J) * Y3ND
1540 LINE (X1, Y1) - (X2, Y2), CL%(CLOR)
1550 FOR K = 0 TO NCOL − 2
1560 X1 = (K) * (2 * XCND) + X0F + (2 * J) * X3ND
1570 Y1 = (Z(J, K) − ZMIN) * 12 / YTC + GY0 + (2 * J) * Y3ND
1580 X2 = (K + 1) * (2 * XCND) + X0F + (2 * J) * X3ND
1590 Y2 = (Z(J, K + 1) − ZMIN) * 12 / YTC + GY0 + (2 * J) * Y3ND

3-D CHARTS AND SURFACE MODELS

1600
1610
1620
1640
1650
1660
1670
1680
1690
1695
1696
1700
1710
1920
1950

169

LINE (X1, Y1) - (X2, Y2), CL%(CLOR)
NEXT K
X1 = X2: Y1 = Y2
X2 = X1: Y2 = GY0 + (2 * J) * Y3ND
LINE (X1, Y1) − (X2, Y2), CL%(CLOR)
X1 = X2: Y1 = Y2
X2 = (XMIN) * 36 / XTC + X0F + (2 * J) * X3ND
Y2 = Y1
LINE (X1, Y1) − (X2, Y2), CL%(CLOR)
IF SCR% <> 2 THEN 1920
IF CLOR = 2 THEN 1920
PAINT (X2 + 10, Y2 + 1), 0, CL%(CLOR)
NEXT CLOR
NEXT J
GOTO 9500
APPENDIX E.3:
3-D LINE PROFILES COMPUTER PROGRAM “GRAPH-E3”

This program was discussed in Section 5.3.2 and displays topographic data (‘.CON’) or surface data (‘.EQD’) as a 3-D
line profile.
3-D line profiles
(a) Initialization and control

Line numbers 10–90

See the notes for section (a) of Appendix E.2.
(b) Data loading

Line numbers 100–180

See the notes for section (b) of Appendix D.2.
(c) Digital ground model data

Line numbers 200–580

This segment of code displays the maximum and minimum X, Y and Z values in the data file. If a colour screen is being
used, the string C$ sets up the colour shading for the line profiles.
(d) 3-D line profile display

Line numbers 4000–4330

This is the main part of the program, and sets up an isometric projection of the digital ground model. If a colour screen
is being used, a colour shaded panel is displayed on the right-hand side of the screen to identify the colour shaded levels.
This program also requires the routines (j)–(u), with the exception of (k), (m) and (p), as listed for Appendix E.1. An
additional routine, listed in Appendix A.13, is also required at Line 7800.
“GRAPH-E3”—BASIC program

170

APPENDICES

10 REM Presentation Graphics Appendix E.3 - 3D Graphs
14 REM (C) Copyright P.H.Milne 1990 - 3D Line Profile
16 REM ALL RIGHTS RESERVED
20 REM VERSION PC-1.00, 1990: **** Maximum 50,50 Data ****
30 CLEAR
40 ON ERROR GOTO 10000
50 PCF$ = "PGSCRDSK.PGD"
60 DIM Z(50, 50), CL%(15)
70 GX0 = 70: GY0 = 50: A$ = "*": DATBX = 0
80 GOSUB 8000: REM Check Screen & Disc
90 WINDOW (0, 0) - (639, 199)
100 CLS: PC$ = "3D Profile"
110 GOSUB 8200: REM Check ID File and DATA
120 LOCATE 15, 10: PRINT "Number of Rows = "; NROW
130 LOCATE 17, 10: PRINT "Number of Columns = "; NCOL
140 LOCATE 20, 10: PRINT "Do you wish to VIEW Graph (Y/N) ";
145 A$ = INPUT$(1)
150 IF INSTR("YNyn", A$) = 0 THEN 140
160 IF A$ = "N" OR A$ = "n" THEN 9600
170 SR% = 2: SRX% = 2: SRY% = 1
180 IF SCR% = 2 THEN SRH% = 2 ELSE SRH% = 1
200 CLS: GOSUB 9000
210 LOCATE 6, 10: PRINT "Digital Ground Model - "; DFILEN$
220 LOCATE 10, 10: PRINT "X-AXIS : Min = "; XMIN
230 LOCATE 10, 40: PRINT ": Max = "; XMAX
240 LOCATE 12, 10: PRINT "Y-AXIS : Min = "; YMIN
250 LOCATE 12, 40: PRINT ": Max = "; YMAX
260 LOCATE 14, 10: PRINT "Z-AXIS : Min = "; ZMIN
270 LOCATE 14, 40: PRINT ": Max = "; ZMAX
400 LOCATE 20, 10: PRINT "Display 3D Profile (Y/N) ";
410 A$ = INPUT$(1)
420 IF INSTR("YNyn", A$) = 0 THEN 400
430 IF A$ = "N" OR A$ = "n" THEN 9600
440 GOSUB 8500: CLS
500 NOCL = 13: RGB% = 15
510 C$ = "1314051204101102030901060815"
520 FOR I = 0 TO NOCL
530 CL%(I) = VAL(MID$(C$, 1 * 2 + 1, 2))
540 NEXT I
550 TCC = (ZMAX − ZMIN) / 14
560 GOSUB 7100
570 HC = INT(ZMAX / TCC) * TCC: LC = INT(ZMIN / TCC) * TCC
580 NOCL = (HC − LC) / TCC
3995 REM ***** Screen Plotting Routine *****
4000 DISP% = 1: YCEN = 0: XCEN = 0: SX = 160 * SRX%: SY = 100
4003 IF SCR% <> 2 THEN RGB% = 2 ELSE RGB% = 12
4005 IF SCR% <> 2 THEN 4010
4007 SCREEN 9: COLOR 15, 0
4008 GX = GX0: GY = GY0