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

  1. 100 rem starplot 1.0
  2. 110 rem copyright @ 1987
  3. 120 rem by stephen shervais jr
  4. 130 rem 4868 langer ln
  5. 140 rem woodbridge, va, 22193
  6. 150 rem compuserve 72060,573
  7. 160 print"this program is designed to compute"
  8. 170 print"the distance between stars near the sun"
  9. 180 print"in cartesian coordinates aligned with"
  10. 190 print"the plane of the ecliptic":print
  11. 200 def fna(q)=(int(q)/57.296)+((q-int(q))/60/57.296)
  12. 210 rem **** input or output *****
  13. 220 print"do you wish to create a new file or print out an old one?"
  14. 230 print
  15. 240 print"1. new file"
  16. 250 print"2. old file: cartesian coordinates"
  17. 260 print"3. old file: distances"
  18. 270 print
  19. 280 get a1$: if a1$="" then 280
  20. 290 if a1$="1" then gosub 340
  21. 300 if a1$="2" then gosub760: gosub970
  22. 310 if a1$="3" then gosub760: gosub1120
  23. 320 end
  24. 330 rem **** input new file ****
  25. 340 input"total number of star systems";s1:s1=s1-1
  26. 350 dim s$(s1), s(s1,8)
  27. 360 for t=0 to s1
  28. 370 print"[146]system";t+1
  29. 380 input"system name     ";s$(t)
  30. 390 input"right ascension ";s(t,0)
  31. 400 input"declination     ";s(t,1)
  32. 410 input"distance, ly    ";s(t,4)
  33. 420 rem **** error check ****
  34. 430 print
  35. 440 print"check:     name "; s$(t)
  36. 450 print"           r.a. "; s(t,0)
  37. 460 print"           dec  "; s(t,1)
  38. 470 print"           dist "; s(t,4)
  39. 480 input"is this correct (y/n)  y[157][157][157]";a2$
  40. 490 if a2$<>chr$(89) then 370
  41. 500 s(t,2)=fna(s(t,0))*15
  42. 510 s(t,3)=fna(s(t,1))
  43. 520 gosub 570:rem *** xyz coords ***
  44. 530 next t
  45. 540 gosub 650:rem ** output to file **
  46. 550 return
  47. 560 rem ** ecliptic cartesian conv **
  48. 570 x=s(t,4)*sin((90/57.296)-s(t,3))*cos(s(t,2))
  49. 580 s(t,5)=x
  50. 590 y=s(t,4)*sin((90/57.296)-s(t,3))*sin(s(t,2))
  51. 600 s(t,6)=y
  52. 610 z=s(t,4)*cos((90/57.296)-s(t,3))
  53. 620 s(t,7)=z
  54. 630 return
  55. 640 rem *** output to disk ***
  56. 650 input "new file name?";a3$
  57. 660 open14,8,14,"0:"+a3$+",s,w"
  58. 670 for t=0 to s1
  59. 680 print#14,s$(t)
  60. 690 for i=0 to 7
  61. 700 print#14,s(t,i)
  62. 710 next i
  63. 720 next t
  64. 730 print#14:close14
  65. 740 return
  66. 750 rem *** input from disk ***
  67. 760 input "old file name ";a3$
  68. 770 print"do you want to output to screen,"
  69. 780 print"or printer?":print
  70. 790 print"1. output to screen"
  71. 800 print"2. output to printer"
  72. 810 get b1$: if b1$="" then 810
  73. 820 if b1$<>"1" and b1$<>"2" then 810
  74. 830 print
  75. 840 input "number of star systems";s1:s1=s1-1
  76. 850 if s<0 then return
  77. 860 dim s$(s1), s(s1,8)
  78. 870 open10,8,10,"0:"+a3$+",s,r"
  79. 880 for t=0 to s1
  80. 890 input#10,s$(t)
  81. 900 for i=0 to 7
  82. 910 input#10,s(t,i)
  83. 920 next i
  84. 930 next t
  85. 940 print#10:close10
  86. 950 return
  87. 960 rem *** ecliptic output ***
  88. 970 open4,3: if b1$="2" then close4: open4,4
  89. 980 for t=0 to s1
  90. 990 print#4
  91. 1000 print#4,s$(t)
  92. 1010 print#4,"right ascension ";s(t,0);"hours.minutes"
  93. 1020 print#4,"    declination ";s(t,1);"degrees.minutes"
  94. 1030 print#4,"      distance= ";s(t,4);"light years"
  95. 1040 print#4,"             x= ";s(t,5);"light years"
  96. 1050 print#4,"             y= ";s(t,6);"light years"
  97. 1060 print#4,"             z= ";s(t,7);"light years"
  98. 1070 if b1$="1" then gosub 1340
  99. 1080 next t
  100. 1090 print#4:close4
  101. 1100 return
  102. 1110 rem *** distance output ***
  103. 1120 open4,3: if b1$="2" then close4: open4,4
  104. 1130 print#4,"distance from sun to ":print
  105. 1140 for t=0 to s1
  106. 1150 print#4,s$(t);tab(25-len(s$(t)));s(t,4)
  107. 1155 if b1$="1" then gosub 1440
  108. 1160 next t
  109. 1170 print#4:close4
  110. 1180 print:input"maximum trip distance ";d2:print
  111. 1190 open4,3: if b1$="2" then close4: open4,4
  112. 1200 for t=0 to s1-1
  113. 1201 gosub 1470
  114. 1210 print#4,"distance from ";s$(t);" to:":print:b2=0
  115. 1220 for u=t+1 to s1
  116. 1230 x1=s(t,5)-s(u,5):x2=x1*x1
  117. 1240 y1=s(t,6)-s(u,6):y2=y1*y1
  118. 1250 z1=s(t,7)-s(u,7):z2=z1*z1
  119. 1260 d1=sqr(x2+y2+z2)
  120. 1270 if d1<d2 then print#4,s$(u);tab(25-len(s$(u)));d1
  121. 1280 if b1$="1" then gosub 1440
  122. 1290 next u
  123. 1300 print:next t
  124. 1310 print#4:close4
  125. 1320 return
  126. 1330 rem *****screen counter****
  127. 1340 b2=b2+8
  128. 1350 if b2=24 then gosub 1370
  129. 1360 return
  130. 1370 print"hit any key to continue[145]"
  131. 1380 get b2$:if b2$="" then 1380
  132. 1390 b2=0: return
  133. 1440 b2=b2+1
  134. 1450 if b2=22 then gosub 1470
  135. 1460 return
  136. 1470 print"hit any key to continue[145]"
  137. 1480 get b2$:if b2$="" then 1480
  138. 1490 print:b2=0: return
  139.