home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_09_1986_Transactor_Publishing.d64
/
projector
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
3KB
|
124 lines
100 rem the projector - perspective plotter
110 rem by ian adam vancouver, bc
120 rem requires hires plotting routines
130 rem from the transactor vol 5 iss 06
140 :
150 rem setup
160 hi=49152: co=49173: dr=49155
170 mo=49161: pr=49182: dm=49167: te=49179
180 cd$=chr$(17)
190 :
200 if peek(hi+1)=194 then 240
210 load"hires",8,1
220 :
230 rem parameters
240 m=20: rem x-dimension
250 n=16: rem y-dimension
260 dim z(m,n),r(m,n)
270 dim xh(m),yh(n),yv(n)
280 :
290 rem data to plot
300 print "creating data"
310 for x=0 to m
320 for y=0 to n
330 z(x,y)=12*x+10*y-1.25*x*y
340 next y: print x: next x
350 :
360 a$="hyperbolic paraboloid": rem title
370 :
380 rem insert other expressions in 330, and change title in 360
390 rem z(x,y)=x*x-x*x*x/22+75*y-12*y*y+y*y*y/2
400 rem a$="contours"
410 rem z(x,y)=560-exp(sqr(abs((x-10)*(y-8)/2)))
420 rem a$="shell roof"
430 rem tm=sqr(x*x+1.5*y*y): z(x,y)=10+sin(tm)+y/4
440 rem a$="gravity waves"
450 rem tm=sqr((x-10)^2+(y-8)^2): z(x,y)=150-tm*55+tm*tm*8-tm*tm*tm/3
460 rem a$="splash"
470 rem a=20-abs(x-10): b=18-abs(y-8): z(x,y)=a: ifb>athenz(x,y)=b
480 rem a$="house"
490 rem z(x,y)=y+(8-y)*((x>4)and(x<16))*((y>3)and(y<13))
500 rem a$="plateau"
510 rem or read empirical results from data
520 :
530 rem projection
540 theta=60: rem default angle
550 print cd$"enter viewing angle, or press return
560 [153] "for 60 degrees:
570 input th
580 th=th*3.14159265/180
590 tmp=120*cos(th)
600 xgrid=int((309-tm)/m)
610 ygrid=int(96*sin(th)/n)
620 ystp=int(tm/n)
630 :
640 rem calculate offsets
650 for x=0 to m
660 xhriz(x)=10+x*xg
670 next
680 for y=0 to n
690 yhriz(y)=y*ys
700 yvert(y)=10+y*yg
710 next
720 :
730 rem vertical scaling
740 print "scaling data
750 vscalar[178]9e9
760 [129] y[178]0 [164] n
770 a[178]0: [129] x[178]0 [164] m
780 [139] z(x,y)[177]a [167] a[178]z(x,y)
790 [130]: [143] find highest point on line
800 [139] a [167] tmp[178](199[171]yv(y))[173]a
810 [139] vs[177]tm [167] vs[178]tm
820 [130]: [143] select best feasible scale
830 :
840 [143] calculate rise
850 [153] "...still scaling!
860 for y=0 to n
870 tm=yv(y)
880 for x=0 to m
890 r(x,y)=z(x,y)*vs+tm
900 next x,y
910 :
920 rem set up screen
930 sys hi,0,0,8
940 sys dm,1
950 :
960 rem plot horizontal lines
970 for y=0 to n
980 tm=yh(y)
990 sys mo,tm+10,r(0,y)
1000 for x=1 to m
1010 sys dr,tm+xh(x),r(x,y)
1020 next x,y
1030 :
1040 rem plot vertical lines
1050 for x=0 to m
1060 tm=xh(x)
1070 sys mo,tm,r(x,0)
1080 for y=1 to n
1090 sys dr,tm+yh(y),r(x,y)
1100 next y,x
1110 :
1120 rem draw box
1130 sys mo,10,r(0,0)
1140 sys dr,10,10
1150 sys dr,xh(m),10
1160 sys dr,xh(m),r(m,0)
1170 sys mo,xh(m),10
1180 sys dr,xh(m)+yh(n),yv(n)
1190 sys dr,xh(m)+yh(n),r(m,n)
1200 :
1210 rem title
1220 sys co,13: sys pr,1,24,a$
1230 :
1240 rem wait for human
1250 wait 198,1: get b$
1260 sys te
1270 :
1280 print cd$"press r to review from another angle
1290 [153] "press any other key to end
1300 wait 198,1: get b$
1310 if b$="r" then 540
1320 end