kleinigkeiten korrigiert

This commit is contained in:
Wolfgang Nowak 2023-11-14 01:25:31 +01:00
parent d4eb22f246
commit 63d7fa486f

View file

@ -37,20 +37,26 @@ clear, home, curoff, curon = "'\x1b[2J\x1b[H", "\x1b[H", "\x1b[?25l", "\x1b[?25h
xsteps = xmax xsteps = xmax
x = 0 x = 0
y = x**2 y = x**2
starthoehe = 0
startwinkel = 45
startgeschwindigkeit = 23
erde = 9.81 erde = 9.81
mond = 1.6 mond = 1.6
jupiter = 24 jupiter = 24
gravitation = erde gravitation = erde
# in scala the resulting coordinates will be returned
scala = []
# used, if input is disabled
starthoehe = 0
startwinkel = 26
startgeschwindigkeit = 23
loeschen = "n"
######################### # Be a friendly host, lets have a talk.
starthoehe = float(input("Starthöhe: ")) # comment out to speed up testing
startwinkel = float(input("Startwinkel: ")) * deg2rad starthoehe = float(input("Starthöhe in Metern, empf: 0-20: "))
startgeschwindigkeit = float(input("Startgeschwindigkeit: ")) startwinkel = float(input("Startwinkel 0° - 90°: ")) * deg2rad
startgeschwindigkeit = float(input("Startgeschwindigkeit Meter (zb 20) pro Sekunde: "))
loeschen = input("Kuh löschen? (y/n)")
####
# Calculate time of flight # Calculate time of flight
flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation
@ -75,31 +81,38 @@ print(
"\nwurfweite: ", "\nwurfweite: ",
wurfweite, wurfweite,
"\nstartwinkel: ", "\nstartwinkel: ",
startwinkel, startwinkel / deg2rad,
"\nstartgeschwindigkeit: ", "\nstartgeschwindigkeit: ",
startgeschwindigkeit, startgeschwindigkeit,
"\nstarthroehe: ", "\nstarthoehe: ",
starthoehe, starthoehe,
"hoehe: ", "\nhoehe: ",
hoehe, hoehe,
) )
a = input("CR please:") bla = input("CR please:")
# position cursor down left corner # position cursor down left corner
curpos(1, ymax) curpos(1, ymax)
# cowlenght ist 2, is cow is an UTF8-Icon, otherwise 1 # cowlength is 2, if cow is an UTF8-Icon, otherwise 1
for x in range(1, xsteps, cowlength): for x in range(1, xsteps, cowlength):
# the formula, which genereates the y position for the corresponding x # the formula, which generates the y position for the corresponding x, shamelessly ripped from some schoolbook and modified.
yold = y
y = (-(gravitation / (2 * startgeschwindigkeit**2 * cos(startwinkel) ** 2)) * x**2) + (tan(startwinkel) * x + starthoehe) y = (-(gravitation / (2 * startgeschwindigkeit**2 * cos(startwinkel) ** 2)) * x**2) + (tan(startwinkel) * x + starthoehe)
# Ensure, that nothing has to be drawn outside the viewport # Ensure, that nothing has to be drawn outside the viewport
if y < ymax and y > ymin: if y < ymax and y > ymin:
curpos(x, y) curpos(x, y)
print(cow, end="") print(cow, end="")
time.sleep(0.01) # Stash awa the coordinates into scala, which will be returned
scala += [x, int(y * 10 + 5) / 10]
time.sleep(0.03)
if loeschen == "y":
curpos(x - 2, yold)
print(" ", end="")
curpos(1, 1) curpos(0, 0)
# print(scala)
sys.exit(curon + "Moooooooooooo.") sys.exit(curon + "Moooooooooooo.")