From 63d7fa486fbf7555bf031613d37f1f62db925d52 Mon Sep 17 00:00:00 2001 From: Wolfgang Nowak Date: Tue, 14 Nov 2023 01:25:31 +0100 Subject: [PATCH] kleinigkeiten korrigiert --- parabeltest.py | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/parabeltest.py b/parabeltest.py index 6d5040a..2dd17ec 100755 --- a/parabeltest.py +++ b/parabeltest.py @@ -37,20 +37,26 @@ clear, home, curoff, curon = "'\x1b[2J\x1b[H", "\x1b[H", "\x1b[?25l", "\x1b[?25h xsteps = xmax x = 0 y = x**2 -starthoehe = 0 -startwinkel = 45 -startgeschwindigkeit = 23 erde = 9.81 mond = 1.6 jupiter = 24 gravitation = erde +# in scala the resulting coordinates will be returned +scala = [] +# used, if input is disabled +starthoehe = 0 +startwinkel = 26 +startgeschwindigkeit = 23 +loeschen = "n" -######################### -starthoehe = float(input("Starthöhe: ")) -startwinkel = float(input("Startwinkel: ")) * deg2rad -startgeschwindigkeit = float(input("Startgeschwindigkeit: ")) - +# Be a friendly host, lets have a talk. +# comment out to speed up testing +starthoehe = float(input("Starthöhe in Metern, empf: 0-20: ")) +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 flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation @@ -75,31 +81,38 @@ print( "\nwurfweite: ", wurfweite, "\nstartwinkel: ", - startwinkel, + startwinkel / deg2rad, "\nstartgeschwindigkeit: ", startgeschwindigkeit, - "\nstarthroehe: ", + "\nstarthoehe: ", starthoehe, - "hoehe: ", + "\nhoehe: ", hoehe, ) -a = input("CR please:") +bla = input("CR please:") # position cursor down left corner 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): - # 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) # Ensure, that nothing has to be drawn outside the viewport if y < ymax and y > ymin: curpos(x, y) 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.")