home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_09_1986_Transactor_Publishing.d64 / projector (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  3KB  |  124 lines

  1. 100 rem the projector - perspective plotter
  2. 110 rem by  ian adam  vancouver, bc
  3. 120 rem requires hires plotting routines
  4. 130 rem from the transactor vol 5 iss 06
  5. 140 : 
  6. 150 rem setup
  7. 160 hi=49152: co=49173: dr=49155
  8. 170 mo=49161: pr=49182: dm=49167: te=49179
  9. 180 cd$=chr$(17)
  10. 190 :
  11. 200 if peek(hi+1)=194 then 240
  12. 210 load"hires",8,1
  13. 220 : 
  14. 230 rem parameters
  15. 240 m=20: rem x-dimension
  16. 250 n=16: rem y-dimension
  17. 260 dim z(m,n),r(m,n)
  18. 270 dim xh(m),yh(n),yv(n)
  19. 280 : 
  20. 290 rem data to plot
  21. 300 print "creating data"
  22. 310 for x=0 to m
  23. 320 for y=0 to n
  24. 330 z(x,y)=12*x+10*y-1.25*x*y
  25. 340 next y: print x: next x
  26. 350 : 
  27. 360 a$="hyperbolic paraboloid": rem title
  28. 370 : 
  29. 380 rem insert other expressions in 330, and change title in 360
  30. 390 rem z(x,y)=x*x-x*x*x/22+75*y-12*y*y+y*y*y/2
  31. 400 rem a$="contours"
  32. 410 rem z(x,y)=560-exp(sqr(abs((x-10)*(y-8)/2)))
  33. 420 rem a$="shell roof"
  34. 430 rem tm=sqr(x*x+1.5*y*y): z(x,y)=10+sin(tm)+y/4
  35. 440 rem a$="gravity waves"
  36. 450 rem tm=sqr((x-10)^2+(y-8)^2): z(x,y)=150-tm*55+tm*tm*8-tm*tm*tm/3
  37. 460 rem a$="splash"
  38. 470 rem a=20-abs(x-10): b=18-abs(y-8): z(x,y)=a: ifb>athenz(x,y)=b
  39. 480 rem a$="house"
  40. 490 rem z(x,y)=y+(8-y)*((x>4)and(x<16))*((y>3)and(y<13))
  41. 500 rem a$="plateau"
  42. 510 rem or read empirical results from data
  43. 520 : 
  44. 530 rem projection
  45. 540 theta=60: rem default angle
  46. 550 print cd$"enter viewing angle, or press return
  47. 560 [153] "for 60 degrees: 
  48. 570 input th
  49. 580 th=th*3.14159265/180
  50. 590 tmp=120*cos(th)
  51. 600 xgrid=int((309-tm)/m)
  52. 610 ygrid=int(96*sin(th)/n)
  53. 620 ystp=int(tm/n)
  54. 630 : 
  55. 640 rem calculate offsets
  56. 650 for x=0 to m
  57. 660 xhriz(x)=10+x*xg
  58. 670 next
  59. 680 for y=0 to n
  60. 690 yhriz(y)=y*ys
  61. 700 yvert(y)=10+y*yg
  62. 710 next
  63. 720 : 
  64. 730 rem vertical scaling
  65. 740 print "scaling data
  66. 750 vscalar[178]9e9
  67. 760 [129] y[178]0 [164] n
  68. 770 a[178]0: [129] x[178]0 [164] m
  69. 780 [139] z(x,y)[177]a [167] a[178]z(x,y)
  70. 790 [130]: [143] find highest point on line
  71. 800 [139] a [167] tmp[178](199[171]yv(y))[173]a
  72. 810 [139]  vs[177]tm  [167]  vs[178]tm
  73. 820 [130]: [143] select best feasible scale
  74. 830 :
  75. 840 [143] calculate rise
  76. 850 [153] "...still scaling!
  77. 860 for y=0 to n
  78. 870 tm=yv(y)
  79. 880 for x=0 to m
  80. 890 r(x,y)=z(x,y)*vs+tm
  81. 900 next x,y
  82. 910 : 
  83. 920 rem set up screen
  84. 930 sys hi,0,0,8
  85. 940 sys dm,1
  86. 950 : 
  87. 960 rem plot horizontal lines
  88. 970 for y=0 to n
  89. 980 tm=yh(y)
  90. 990 sys mo,tm+10,r(0,y)
  91. 1000 for x=1 to m
  92. 1010 sys dr,tm+xh(x),r(x,y)
  93. 1020 next x,y
  94. 1030 : 
  95. 1040 rem plot vertical lines
  96. 1050 for x=0 to m
  97. 1060 tm=xh(x)
  98. 1070 sys mo,tm,r(x,0)
  99. 1080 for y=1 to n
  100. 1090 sys dr,tm+yh(y),r(x,y)
  101. 1100 next y,x
  102. 1110 : 
  103. 1120 rem draw box
  104. 1130 sys mo,10,r(0,0)
  105. 1140 sys dr,10,10
  106. 1150 sys dr,xh(m),10
  107. 1160 sys dr,xh(m),r(m,0)
  108. 1170 sys mo,xh(m),10
  109. 1180 sys dr,xh(m)+yh(n),yv(n)
  110. 1190 sys dr,xh(m)+yh(n),r(m,n)
  111. 1200 :
  112. 1210 rem title
  113. 1220 sys co,13: sys pr,1,24,a$
  114. 1230 :
  115. 1240 rem wait for human
  116. 1250 wait 198,1: get b$
  117. 1260 sys te
  118. 1270 :
  119. 1280 print cd$"press r to review from another angle
  120. 1290 [153] "press any other key to end
  121. 1300 wait 198,1: get b$
  122. 1310 if b$="r" then 540
  123. 1320 end
  124.