In [1]:
import sympy as sp
sp.init_printing()
In [2]:
t, t0, t1, g, r0x, r0y, r1x, r1y = sp.symbols('t t_0 t_1 g r_0x r_0y r_1x r_1y')
adat=[(t0, 0), (t1, 1), (g,9.81), (r0x, 0), (r0y, 0), (r1x, 4.6), (r1y, 1)]
adat
Out[2]:
$$\left [ \left ( t_{0}, \quad 0\right ), \quad \left ( t_{1}, \quad 1\right ), \quad \left ( g, \quad 9.81\right ), \quad \left ( r_{0x}, \quad 0\right ), \quad \left ( r_{0y}, \quad 0\right ), \quad \left ( r_{1x}, \quad 4.6\right ), \quad \left ( r_{1y}, \quad 1\right )\right ]$$

a) $\mathbf{v}\left(t_0\right) = \mathbf{v}_0 = ?$, $\mathbf{v}\left(t_1\right) = \mathbf{v}_1 = ?$

In [3]:
v0x, v0y = sp.symbols('v_0x v_0y')
In [4]:
a = sp.Matrix([0,-g])
a
Out[4]:
$$\left[\begin{matrix}0\\- g\end{matrix}\right]$$
In [5]:
v0 = sp.Matrix([v0x, v0y])
v = sp.integrate(a,t) + v0
v
Out[5]:
$$\left[\begin{matrix}v_{0x}\\- g t + v_{0y}\end{matrix}\right]$$
In [6]:
r = sp.integrate(v,t) + sp.Matrix([r0x, r0y])
r
Out[6]:
$$\left[\begin{matrix}r_{0x} + t v_{0x}\\- \frac{g t^{2}}{2} + r_{0y} + t v_{0y}\end{matrix}\right]$$
In [7]:
megov0=sp.solve(r.subs(t,t1)-sp.Matrix([r1x, r1y]),[v0x, v0y])
megov0
Out[7]:
$$\left \{ v_{0x} : \frac{1}{t_{1}} \left(- r_{0x} + r_{1x}\right), \quad v_{0y} : \frac{1}{t_{1}} \left(\frac{g t_{1}^{2}}{2} - r_{0y} + r_{1y}\right)\right \}$$
In [8]:
v0.subs(megov0).subs(adat)
Out[8]:
$$\left[\begin{matrix}4.6\\5.905\end{matrix}\right]$$
In [9]:
v0.subs(megov0).subs(adat).norm()
Out[9]:
$$7.48525383671122$$
In [10]:
v1 = v.subs(t,t1).subs(megov0).subs(adat)
v1
Out[10]:
$$\left[\begin{matrix}4.6\\-3.905\end{matrix}\right]$$
In [11]:
v1.norm()
Out[11]:
$$6.03398914483611$$

b) $y\left(x\right) = f\left(x\right)$

In [12]:
x = sp.Symbol('x')
In [13]:
megot = sp.solve([x-r[0]],[t])
megot
Out[13]:
$$\left \{ t : \frac{1}{v_{0x}} \left(- r_{0x} + x\right)\right \}$$
In [14]:
y = r[1].subs(megot).subs(megov0)
y
Out[14]:
$$- \frac{g t_{1}^{2} \left(- r_{0x} + x\right)^{2}}{2 \left(- r_{0x} + r_{1x}\right)^{2}} + r_{0y} + \frac{1}{- r_{0x} + r_{1x}} \left(- r_{0x} + x\right) \left(\frac{g t_{1}^{2}}{2} - r_{0y} + r_{1y}\right)$$
In [15]:
y.subs(adat)
Out[15]:
$$- 0.231805293005671 x^{2} + 1.28369565217391 x$$

A pálya csúcspontja

In [16]:
megoxcsucs=sp.solve([sp.diff(y,x)],[x])
megoxcsucs
Out[16]:
$$\left \{ x : \frac{1}{g t_{1}^{2}} \left(\frac{g r_{0x}}{2} t_{1}^{2} + \frac{g r_{1x}}{2} t_{1}^{2} + r_{0x} r_{0y} - r_{0x} r_{1y} - r_{0y} r_{1x} + r_{1x} r_{1y}\right)\right \}$$
In [17]:
x.subs(megoxcsucs).subs(adat)
Out[17]:
$$2.76890927624873$$
In [18]:
y.subs(megoxcsucs).subs(adat)
Out[18]:
$$1.77721839959225$$

c) hodográf

In [19]:
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

mpl.rc('font', size =  12)
In [34]:
plt.figure(figsize = (18/2.54,20/2.54))
tLista = np.linspace(float(t0.subs(adat)),float(t1.subs(adat)),10)

cmap = mpl.cm.get_cmap('viridis')
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=0, vmax=1))
# fake up the array of the scalar mappable. Urgh...
sm._A = []
plt.colorbar(sm)

plt.plot([0,5],[-5,6],alpha=0)
for i in np.arange(0,len(tLista)):
    plt.arrow(0,0,
              float(v[0].subs(t,tLista[i]).subs(megov0).subs(adat)),
              float(v[1].subs(t,tLista[i]).subs(megov0).subs(adat)),
              color = cmap(tLista[i]), head_width = 0.2)

plt.xlim([0,5])
plt.ylim([-5,6])
plt.grid()
plt.xlabel(r'$v_x \, \left[\mathrm{m/s}\right]$')
plt.ylabel(r'$v_y \, \left[\mathrm{m/s}\right]$')
plt.axis('scaled')

plt.show()

d) $\mathbf{a}_\mathrm{t}\left(t_1\right)$, $\mathbf{a}_\mathrm{n}\left(t_1\right)$

In [21]:
et1 = (v1/v1.norm())
et1
Out[21]:
$$\left[\begin{matrix}0.762348073485794\\-0.647167223252614\end{matrix}\right]$$
In [22]:
at1 = et1*(a.dot(et1)).subs(t,t1).subs(adat)
at1
Out[22]:
$$\left[\begin{matrix}4.83992718838255\\-4.10867731970301\end{matrix}\right]$$
In [23]:
an1 = (a - at1).subs(t,t1).subs(adat)
an1
Out[23]:
$$\left[\begin{matrix}-4.83992718838255\\-5.70132268029699\end{matrix}\right]$$
In [24]:
en1 = an1.normalized()
en1
Out[24]:
$$\left[\begin{matrix}-0.647167223252614\\-0.762348073485794\end{matrix}\right]$$
In [25]:
a1 = a.subs(t,t1).subs(adat)
a1
Out[25]:
$$\left[\begin{matrix}0\\-9.81\end{matrix}\right]$$
In [26]:
plt.figure(figsize = (18/2.54,20/2.54))
ax = plt.gca()
plt.plot([-10,15],[-15,0], alpha = 0) # belerajzolunk egy áttetsző vonalat, hogy a nyilak helyesen jelenjenek meg
plt.arrow(0,0,float(at1[0,0]),float(at1[1,0]),linestyle = ':',color = '#FF0000', head_width = 1)
plt.arrow(0,0,float(an1[0,0]),float(an1[1,0]),linestyle = ':',color = '#FF0000', head_width = 1)
plt.arrow(0,0,float(a1[0,0]),float(a1[1,0]),color = '#FF0000', head_width = 1)
plt.plot([float(an1[0,0]),float(a1[0,0])],[float(an1[1,0]),float(a1[1,0])],linestyle = ':',color = '#FF0000')
plt.plot([float(at1[0,0]),float(a1[0,0])],[float(at1[1,0]),float(a1[1,0])],linestyle = ':',color = '#FF0000')

plt.arrow(0,0,2*float(v1[0,0]),2*float(v1[1,0]),color = '#0000FF', head_width = 1)

plt.arrow(0,0,5*float(et1[0,0]),5*float(et1[1,0]),color = '#FFA500', head_width = 1)
plt.arrow(0,0,5*float(en1[0,0]),5*float(en1[1,0]),color = '#FFA500', head_width = 1)

# plt.xlim(left = 0, right = 50)
# plt.ylim(bottom = -30, top = 60)
ax.set_xticklabels([])
ax.set_yticklabels([])
plt.axis('scaled')
plt.grid()
plt.show()

e) $\rho\left(t_1\right)$

In [27]:
rho1 = v1.norm()**2/an1.norm()
rho1
Out[27]:
$$4.86840538988757$$