Die Bewegung der Planeten auf Ellipsenbahnen wird durch die Keplerschen
Gesetze beschrieben. Üblicherweise wird dieses sog. Zweikörperproblem durch
die Keplergleichung gelöst. Ich habe es hier ganz anschaulich gemacht und
berechne es direkt, wie von Kepler angegeben: Der Leitsrahl Sonne-Planet
üebrstreicht in gleichen Zeiten gleiche Flächen. Das ist der anschauliche
beleg dafür, dass die Keplerschen Gesetze wirklich gelten.
# Programm Ellipse1
import math
a=1
e=0.6
b=math.sqrt(1-e*e)
f_ellip=math.pi*a*b
# Startpunkt
t=0
u=a*math.cos(t)-e
v=b*math.sin(t)
# Fläche ist erstmal 0
f=0
anzahlSchritte=200
# Schleife durch alle Werte von t
for i in range(0, anzahlSchritte):
t=t+2*math.pi/anzahlSchritte
x=a*math.cos(t)-e
y=b*math.sin(t)
p=math.sqrt((x-u)**2+(y-v)**2)
q=math.sqrt(u**2+v**2)
r=math.sqrt(x**2+y**2)
s=(p+q+r)/2
f=f+math.sqrt(s*(s-p)*(s-q)*(s-r))
u=x
v=y
# Ephemeriden drucken
print("Teilfläche (%):"+str(100*f/f_ellip)),
T=180*math.atan2(y,x)/math.pi
print("wahre Anomalie:",T)
print("")
print("Berechnet: "+str(f))
print("Theorie: "+str(f_ellip))
diff=abs(f-f_ellip)
print("Differenz "+str(diff))
name = input("Fertig?")
# Programm Ellipse2
import math
# Grafik ca. von -300 bis 300
from turtle import *
def plot(x,y):
penup()
goto(x,y)
pendown()
dot(4)
hideturtle()
# Hauptprogramm
import math
a=1
e=0.3
b=math.sqrt(1-e*e)
plot(300*e,0) # Sonne
t=0
u=a*math.cos(t)-e
v=b*math.sin(t)
plot(300*(u+e), 300*v)
f=0
i=1
anzahlPunkte = 32
for i in range(anzahlPunkte-1):
while f<math.pi*a*b/anzahlPunkte:
t=t+math.pi/1000
x=a*math.cos(t)-e
y=b*math.sin(t)
p=math.sqrt((x-u)**2+(y-v)**2)
q=math.sqrt(u**2+v**2)
r=math.sqrt(x**2+y**2)
s=(p+q+r)/2
f=f+math.sqrt(s*(s-p)*(s-q)*(s-r))
u=x
v=y
f=f-math.pi*a*b/anzahlPunkte
plot(300*(x+e),300*y)
done()