# Demo entry 1468790

Tiro parabolico

Submitted by Larry on Mar 14, 2015 at 23:52
Language: Python. Code size: 2.3 kB.

```#!/bin/bash/python
import numpy  as np
from visual import*
from visual.graph import*
import random

#Configuracion de escenario de simulasion
scene=display(tittle='Movimiento con MDF',x=5,y=5, heigth=5, center=(2,2,2),
background=(1,1,1))
scene.autoscale=5

#Ventanas para las graficas
graph1= gdisplay(x=0,y=0,height=150,title='x vs y',xtitle='X',ytitle='Y',
foreground=color.black, background=color.white)

#Se agregan las dos curvas grafica
MDF=gdots(gdisplay=graph1, color=color.red)
exacta= gdots(gdisplay=graph1, color=color.blue)

#Datos de la simulacion
#AlcanceTotal=(np.sin(2*theta)*(rap**2))/(2*g)
D=np.arange(0,200,1)
#Movimiento

#while parti1.pos.y>=0:

#Solucion Analitica
#       parti1.vel += parti1.ace*dt
#      parti1.pos += parti1.vel*dt+(parti1.ace*(dt**2))*0.5

#exacta.plot(pos=(parti1.pos.x,parti1.pos.y))
#rate(100)

i=0
while i<=100:
#Objetos de la simulacion

suelo=box(pos=(20,-1.5,0), size=(100,1,20), color= color.red)

#Constantes
theta=np.pi/3
speed=45
m1=3
t=0
dt=0.01
g=9.8
lamda=0.1
betha=random.uniform(0,0.01)
lamda_p=lamda/m1
r=0

#Vetores
parti1.vel= speed* vector( np.cos(theta), np.sin(theta),0)
parti1.ace=vector(0,-g,0)
parti2.vel= speed* vector( np.cos(theta), np.sin(theta),0)
parti2.ace=vector(0,-g,0)
rap=((parti1.vel.x)**2+(parti1.vel.y)**2+(parti1.vel.z)**2)**0.5

while parti2.pos.y>=0:

#Solucion usando MDF
rap=((parti1.vel.x)**2+(parti1.vel.y)**2+(parti1.vel.z)**2)**0.5
betha=random.uniform(0,0.01)
parti2.ace2=parti2.ace-lamda_p*parti2.vel-(betha*rap*parti2.vel)/m1
amedio=(parti2.ace+parti2.ace2)*0.5

parti2.vel2=parti2.vel
parti2.vel += amedio*dt
vmedio=(parti2.vel+parti2.vel2)*0.5
parti2.pos += vmedio*dt+(amedio*(dt**2))*0.5

rate(100)
MDF.plot(pos=(parti2.pos.x,parti2.pos.y))
D[i]=parti2.pos.x
print D[i]
i+=1

print 'el coeficiente es: ',betha
print 'El alcanse total de la particula 1 es:  ', parti1.pos.x
print 'El alcanse total de la particula 2 es:  ', parti2.pos.x
```

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.