#
import matplotlib.pyplot as PLT
import numpy as NUM
#
def DegRad(deg):
    return deg / 180.0 * NUM.pi
#
def RadDeg(rad):
    return rad / NUM.pi * 180.0
#
print('')
print('*** Schiefer Wurf')
print('')
#
# Make Data:
G = 9.81  # [m/s2] - Erdbeschleunigung
PSI = DegRad(45) # Abwurfwinkel [deg]
V0 = 4.2 # [m/s] - Resultierende Startgeschwindigkeit
V0X = V0 * NUM.cos(PSI)
V0Y = V0 * NUM.sin(PSI)
X0 = 2.0  # [m] - X-Startpunkt
Y0 = 3.0  # [m] - Y-Starthoehe
#
VT = NUM.linspace(0, 1.2, 30)          # [s] - Zeitvektor
VVX = NUM.linspace(V0X, V0X, 30)       # [m/s] - Geschwindigkeitsvektor X
VVY = -G * VT                          # [m/s] - Geschwindigkeitsvektor Y
VX = V0X * VT + X0                     # [m] - Ortsvektor X
VY = Y0 + V0Y * VT - 0.5 * G * VT * VT # [m] - Ortsvektor Y
# Bahnkurve CY = Y(X)
VCY = Y0 - G * (VX - X0) * (VX - X0) / 2 / V0X / V0X + (VX - X0) * V0Y / V0X
#
# Wurfwinkel psi [deg]
print('Wurfwinkel psi = {0} deg'.format(RadDeg(PSI)))
# Steigzeit ts [s]
TS = V0Y / G
print('Steigzeit ts = {0} s'.format(TS))
# Wurfhoehe yh [m]
YH = V0Y * V0Y / 2 / G + Y0
print('Wurfhoehe yh = {0} m'.format(YH))
# Wurfzeit tw [s]
D = V0Y * V0Y / G / G + 2 * Y0 / G
TW = V0Y / G + NUM.sqrt(D)
print('Wurfzeit tw = {0} s'.format(TW))
# Wurfweite xw [m]
XW = X0 + V0X * V0Y / G + V0X * NUM.sqrt(D)
print('Wurfweite xw = {0} s'.format(XW))
# Aufprallgeschwindigkeit vp [m/s]
VV = V0Y - G * TW
VP = NUM.sqrt(V0X * V0X + VV * VV)
print('Aufprallgeschwindigkeit vp = {0} m/s'.format(VP))
#
# Make Plot:
#------------------------------------------------
Figure, (A1, A2) = PLT.subplots(1, 2)
Figure.set_size_inches(12, 8)
#
A1.plot(VT, VX, 'b')
A1.plot(VT, VX, 'ob')
A1.set_title('x(t)')
A1.set(xlabel='t [s]', ylabel='x [m]')
A1.grid(True)
#
A2.plot(VT, VVX, 'g')
A2.plot(VT, VVX, 'go')
A2.set_title('vx(t)')
A2.set(xlabel='t [s]', ylabel='vx [m/s]')
A2.grid(True)
#
PLT.show()
#------------------------------------------------

Figure, (A3, A4) = PLT.subplots(1, 2)
Figure.set_size_inches(12, 8)
#
A3.plot(VT, VY, 'b')
A3.plot(VT, VY, 'ob')
A3.set_title('y(t)')
A3.set(xlabel='t [s]', ylabel='y [m]')
A3.grid(True)
#
A4.plot(VT, VVY, 'g')
A4.plot(VT, VVY, 'go')
A4.set_title('vy(t)')
A4.set(xlabel='t [s]', ylabel='vy [m/s]')
A4.grid(True)
#
PLT.show()
#------------------------------------------------
#
Figure, Axes = PLT.subplots()
Figure.set_size_inches(12, 8)
Axes.set_aspect('equal')
PLT.xlim(0, 7)
PLT.ylim(-2, 5)
#
Axes.plot(VX, VY, 'b')
Axes.plot(VX, VCY, 'or')
Axes.set_title('y = y(x)')
Axes.set(xlabel='x [m]', ylabel='y [m]')
Axes.grid(True)
#
PLT.show()
#
