-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasicExercise 13.py
82 lines (66 loc) · 1.49 KB
/
BasicExercise 13.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python2.6
#_*_coding:utf8_*_
"""
comentarios y documentos
"""
import numpy as np
import matplotlib
import time
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
fig = plt.figure()
#figura1
a1= fig.add_subplot(111)
line1, = a1.plot([],[])
a1.grid()
#declaracion de variable
xn0=eval(raw_input("Introduzca el valor de xn:"))
yn0=eval(raw_input("Introduzca el valor de yn:"))
vo=eval(raw_input("Introduzca la amplitud en vo :"))
ta=eval(raw_input("Introduzca el valor del angulo ta :"))
g=9.8
T=0.05
#definimos variables
VOvec=[vo*np.cos((ta*np.pi)/180) , (vo*np.sin((ta*np.pi)/180))]
vox , voy = VOvec
xn1=[]
yn1=[]
vyn=[]
vxn=[]
def calc_xn1(T):
xn1=xn+T*vox
return xn1
def calc_yn1(T):
yn1=yn+T*voy
return yn1
def calc_vyn(T):
vyn=voy+T*g
return vyn
def anima():
yn=[]
xn=[]
v=[]
H=[]
g=9.8
xn.append(xn0)
yn.append(yn0)
v.append(voy)
i=1
T=0.05
t=T
k=1
H=((voy**2)/(2*g))+(yn)
while (k>0):
xn.append(xn0+vox*t)
v.append(v[i-1]-T*g)
yn.append(yn[i-1]+T*v[i])
#grafica x vs y
line1.set_data(xn,yn)
a1.set_xlim(0,xn[len(xn)-1])
a1.set_ylim(0,H)
t=t+T
i=i+1
if (yn[i-1]<0):
k=0
#time.sleep(0.1)
fig.canvas.draw()