Made some improvements.
This commit is contained in:
parent
72f4674ee1
commit
cc7685c458
1 changed files with 20 additions and 11 deletions
|
@ -8,7 +8,7 @@ from time import sleep
|
|||
|
||||
|
||||
########################################################################################
|
||||
def berechneflugbahn(xmin, xmax, ymin, ymax, xsteps, startwinkel, startgeschwindigkeit, starthoehe=0, gravitation=9.81, xstep=1):
|
||||
def berechneflugbahn(xmax, ymax, steps, startwinkel, startgeschwindigkeit, xmin=0, ymin=0, starthoehe=0, gravitation=9.81, xstep=1):
|
||||
x = 0
|
||||
y = x**2
|
||||
|
||||
|
@ -29,22 +29,31 @@ def berechneflugbahn(xmin, xmax, ymin, ymax, xsteps, startwinkel, startgeschwind
|
|||
* (startgeschwindigkeit * sin(startwinkel) + sqrt(startgeschwindigkeit**2 * sin(startwinkel) ** 2 + 2 * gravitation * starthoehe))
|
||||
) / gravitation
|
||||
|
||||
first_run = True
|
||||
|
||||
# cowlength is 2, if cow is an UTF8-Icon, otherwise 1
|
||||
for x in range(xmin, xsteps - 1, xstep):
|
||||
for x in range(xmin, steps - 1, xstep):
|
||||
# the formula, which generates the y position for the corresponding x, shamelessly ripped from some schoolbook and modified.
|
||||
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:
|
||||
|
||||
if x >= xmax:
|
||||
x = xmax
|
||||
|
||||
if y >= ymax:
|
||||
y = ymax
|
||||
|
||||
elif y <= ymin:
|
||||
y = ymin
|
||||
|
||||
# Stash away the coordinates into scala, which will be returned
|
||||
scala += [x, int((y * 100 + 50) / 100)]
|
||||
|
||||
elif y <= ymin:
|
||||
scala += [x, ymin]
|
||||
if y == ymin and not first_run:
|
||||
break
|
||||
|
||||
else:
|
||||
scala += [x, ymax]
|
||||
first_run = False
|
||||
|
||||
return scala
|
||||
|
||||
|
@ -81,12 +90,12 @@ if __name__ == "__main__":
|
|||
|
||||
# X-Resolution of the display
|
||||
xmax = termsize_xy[0] - 1
|
||||
xsteps = xmax
|
||||
xsteps = xmax * 2
|
||||
ymax = termsize_xy[1]
|
||||
ymin = 0
|
||||
xmin = 0
|
||||
startwinkel = 34
|
||||
startgeschwindigkeit = 31
|
||||
startgeschwindigkeit = 60
|
||||
starthoehe = 0
|
||||
schlafzeit = 0.05
|
||||
###
|
||||
|
@ -98,7 +107,7 @@ if __name__ == "__main__":
|
|||
y = xmin
|
||||
|
||||
# Call the function, which calculates the coordinates)
|
||||
ergebnis = berechneflugbahn(xmin, xmax, ymin, ymax, xsteps, startwinkel, startgeschwindigkeit, starthoehe, g_erde, 2)
|
||||
ergebnis = berechneflugbahn(xmax, ymax, xsteps, startwinkel, startgeschwindigkeit, starthoehe, gravitation=g_erde, xstep=2)
|
||||
print(curoff)
|
||||
# here we draw the cow
|
||||
for count in range(xmin, len(ergebnis), 2):
|
||||
|
|
Loading…
Reference in a new issue