Ich habe hier eine Variante, die ein paar mehr Hilfslinien und Beschrifungen enthält:
Code:
#Programm Raumkr2.py
from turtle import *
from random import *
from math import *
def text(x,y,text):
penup()
goto(60*x-300,60*y-300)
write(text,font=("Arial", 14))
def line(x1,y1,x2,y2):
penup()
goto(60*x1-300,60*y1-300)
pendown()
goto(60*x2-300,60*y2-300)
def plot(x,y): # einen Punkt setzen
penup()
goto(60*x-300,60*y-300)
pendown()
dot(4)
hideturtle()
# Hauptprogramm
tracer(0,0) # Bildschirm aus
r=10
s=0
ds=0.01
y=0
# Koordinatensystem
line(0,0,12,0)
line(0,0,0,11)
line(10,0,10,-0.2)
text(0.9,-0.6,"1")
text(9.8,-0.6,"10")
text(10.8,-0.6,"r in rs")
text(-0.1,-0.6,"0")
# Schwarzschildradius
pencolor("red")
line(1,0.2,1, 10.5)
pencolor("blue")
# eigentliche Rechnung
while r>1.001:
s=s+ds
dr=ds*(sqrt(1-1/r))
r=r-dr
dy=sqrt(ds*ds-dr*dr)
y=y+dy
plot(r, y)
# print(r, s)
print ("s=",s)
update() # Bildschirm an