ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kepler.bas 3.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. 10 REM KEPLER'S EQUATION
  2. 20 REM
  3. 30 P1=PI : D7=P1/180 : R1=1/D7
  4. 40 K=.01720209895
  5. 50 GOSUB 1060
  6. 60 REM
  7. 70 PRINT "PERIHELION DISTANCE Q: "; : INPUT Q
  8. 90 PRINT "ECCENTRICITY "; : INPUT E0
  9. 92 PRINT "STARTING AND ENDING T "; : INPUT T7,T8
  10. 95 FOR T=T7 TO T8 STEP .1
  11. 100 A1=Q/(1-E0) : IF A1<0 THEN M=0 : GO TO 120
  12. 110 N0=K*A1^(-1.5) : M=N0*T
  13. 120 PRINT "MEAN ANOMALY IS ";M*R1;" DEGREES"
  14. 122 PRINT : PRINT
  15. 123 PRINT "METHOD I V R"
  16. 124 PRINT
  17. 130 IF A1<0 THEN 205
  18. 140 IF E0>.99 THEN 170
  19. 150 PRINT "SIMPLE ";
  20. 160 GOSUB 490 : GOSUB 400
  21. 170 PRINT "ENCKE ";
  22. 180 GOSUB 560 : GOSUB 400
  23. 190 PRINT "BINARY ";
  24. 200 GOSUB 260 : GOSUB 400
  25. 205 REM
  26. 210 PRINT "HERRICK ";
  27. 220 GOSUB 640 : GOSUB 440
  28. 230 PRINT "GAUSS ";
  29. 240 GOSUB 850 : GOSUB 440
  30. 245 NEXT T
  31. 250 GO TO 2000
  32. 260 REM BINARY METHOD
  33. 270 REM
  34. 280 F=SGN(M) : M=ABS(M)/(2*P1) : M=(M-INT(M))*2*P1*F
  35. 290 IF M<0 THEN M=M+2*P1
  36. 300 F=1 : IF M>P1 THEN M=2*P1-M : F=-1
  37. 310 E=P1/2 : D=P1/4
  38. 320 FOR I1=1 TO 47
  39. 330 M1=E-E0*SIN(E)
  40. 340 E=E+SGN(M-M1)*D : D=D/2
  41. 350 E1=E
  42. 360 NEXT I1
  43. 370 E=E*F : I=I1-1
  44. 380 RETURN
  45. 390 REM
  46. 400 REM TRUE ANOMALY FROM ECCENTRIC ANOMALY
  47. 410 REM
  48. 420 V=2*ATN(SQR((1+E0)/(1-E0))*SIN(E/2)/COS(E/2))
  49. 430 R=A1*(1-E0*COS(E))
  50. 440 PRINT USING " #### ###.###### ##.#######";I;V*R1;R
  51. 470 RETURN
  52. 480 REM
  53. 490 REM SIMPLE ITERATION
  54. 500 REM
  55. 510 E=M : I=0
  56. 520 E1=M+E0*SIN(E) : I=I+1
  57. 530 IF ABS(E-E1)>1.0000000000000E-10 THEN E=E1 : GO TO 520
  58. 540 RETURN
  59. 550 REM
  60. 560 REM ENCKE ITERATION
  61. 570 REM
  62. 580 E=M : I=0
  63. 590 E1=E+(M+E0*SIN(E)-E)/(1-E0*COS(E)) : I=I+1
  64. 600 IF ABS(E-E1)>1.0000000000000E-10 THEN E=E1 : GO TO 590
  65. 610 RETURN
  66. 620 REM
  67. 640 REM HERRICK'S METHOD
  68. 650 REM
  69. 660 REM ENTER WITH T,E0,Q
  70. 670 REM EXIT WITH TRUE ANOMALY
  71. 680 REM
  72. 682 I=0
  73. 690 P=Q*(1+E0)
  74. 700 C=K*(1+E0)*(1+E0)/(2*P^1.5)
  75. 710 X=SGN(T) : REM ASSUME V +90 OR -90 TO START
  76. 720 L=(1-E0)/(1+E0)
  77. 730 D2=C*(1+L*X*X)/(1+X*X)
  78. 740 C2=X/(1+L*X*X) : K1=X*X*X/(1+E0)
  79. 750 C2=C2+K1*(1/(1+L*X*X)-1/3)
  80. 760 N=0 : S=-1
  81. 770 N=N+1
  82. 775 I=I+1
  83. 780 S=-S
  84. 790 F=K1*S*(L*X*X)^N/(2*N+3)
  85. 800 C2=C2+F : IF ABS(F)>1.0000000000000E-12 THEN 770
  86. 810 D3=T-C2/C : IF ABS(D3)<1.0000000000000E-10 THEN 830
  87. 820 X=X+D2*D3 : GO TO 730
  88. 830 V=2*ATN(X) : R=Q*(1+E0)/(1+E0*COS(V))
  89. 840 RETURN
  90. 850 REM GAUSS METHOD
  91. 860 REM
  92. 870 REM ENTER WITH T,E0,Q; EXIT WITH V,R
  93. 880 REM
  94. 882 I=0
  95. 890 A=SQR((1+9*E0)/10) : B=5*(1-E0)/(1+9*E0)
  96. 900 C=SQR(5*(1+E0)/(1+9*E0))
  97. 910 B1=3*A*K*T/SQR(2*Q*Q*Q)
  98. 920 B2=1 : REM INITIAL ASSUMPTION
  99. 930 W1=B2*B1
  100. 940 B3=ATN(2/W1) : T1=SIN(B3/2)/COS(B3/2)
  101. 950 S1=SGN(T1) : T1=ABS(T1) : T2=T1^(1/3)*S1
  102. 960 G=ATN(T2) : S=2/(SIN(2*G)/COS(2*G))
  103. 970 A2=B*S*S
  104. 980 B0=B2 : B2=0
  105. 982 FOR J=0 TO 7 : B2=B2+B(J)*A2^J : NEXT J
  106. 984 I=I+1
  107. 990 IF ABS(B2-B0)>1.0000000000000E-13 THEN 930
  108. 1000 C1=0 : FOR J=0 TO 7 : C1=C1+G(J)*A2^J : NEXT J
  109. 1010 V1=C*C1*S
  110. 1020 D1=1/(1+A2*C1*C1) : R=Q*D1*(1+V1*V1)
  111. 1030 V=2*ATN(V1)
  112. 1040 RETURN
  113. 1050 REM
  114. 1060 REM COEFFICIENTS
  115. 1080 FOR J=0 TO 7 : READ B(J) : NEXT J
  116. 1090 FOR J=0 TO 7 : READ G(J) : NEXT J
  117. 1100 FOR J=0 TO 7 : READ S(J) : NEXT J
  118. 1110 RETURN
  119. 1120 DATA 1,0,-0.017142857,-0.003809524,-0.001104267
  120. 1130 DATA -0.000367358,-0.000131675,-0.000049577
  121. 1140 DATA 1,0.4,0.21714286,0.12495238,0.07339814
  122. 1150 DATA 0.04351610,0.02592289,0.01548368
  123. 1160 DATA 1,-0.8,0.04571429,0.01523810,0.00562820
  124. 1170 DATA 0.00218783,0.00087905,0.00036155
  125. 2000 END
  126. 2010 REM ------------------------------------------
  127. 2020 REM APPEARED IN ASTRONOMICAL COMPUTING, SKY &
  128. 2030 REM TELESCOPE, AUGUST, 1985
  129. 2040 REM ------------------------------------------