#
import matplotlib.pyplot as PLT
import numpy as NUM
#
print('')
print('*** Senkrechter Wurf')
print('')
#
# Make Data:
G = 9.81  # [m/s2] - Erdbeschleunigung
V0Y = 4.2 # [m/s] - Startgeschwindigkeit
Y0 = 2.0  # [m] - Startort, Y-Offset
#
VT = NUM.linspace(0, 1.2, 30)          # [s] - Zeitvektor
VVY = V0Y - G * VT                     # [m/s] - Geschwindigkeitsvektor
VY = V0Y * VT - 0.5 * G * VT * VT + Y0 # [m] - Ortsvektor
#
# Steigzeit th [s]
TH = V0Y / G
print('Steigzeit th = {0} s'.format(TH))
# Wurfhoehe yh [m]
YH = 0.5 * V0Y * V0Y / G + Y0
print('Wurfhoehe yh = {0} m'.format(YH))
# Wurfdauer td [s]
TD = V0Y / G + NUM.sqrt(V0Y * V0Y / G / G + 2 * Y0 / G)
print('Wurfdauer td = {0} s'.format(TD))
# Aufprallgeschwindigkeit vp [m/s]
VP = NUM.sqrt(V0Y * V0Y + 2 * G * Y0)
print('Aufprallgeschwindigkeit vp = {0} m/s'.format(VP))
#
# Make Plot:
Figure, (Axes1, Axes2) = PLT.subplots(1, 2)
Figure.set_size_inches(12, 8)
#
Axes1.plot(VT, VY, 'b')
Axes1.plot(VT, VY, 'ob')
Axes1.set_title('y(t)')
Axes1.set(xlabel='t [s]', ylabel='y [m]')
Axes1.grid(True)
#
Axes2.plot(VT, VVY, 'g')
Axes2.plot(VT, VVY, 'go')
Axes2.set_title('v(t)')
Axes2.set(xlabel='t [s]', ylabel='v [m/s]')
Axes2.grid(True)
#
PLT.show()
