friends, I'm new to python and trying to plot three curves with each other, but I have some problems which I can't figure out:
I try to solve trajectory of a ball with different vectors:
1- different x values 2- different velocity values 3- different angle values
import numpy as np
import math as m
import matplotlib.pylab as pl
def ball(x, theta, v0, y0):
v0= v0/3.6
g = 9.81
theta = m.radians(theta)
return x * m.tan(theta) + y0\
- 1./(2.0 * v0 ** 2.0 ) * g * x**2.0 / (m.cos(theta)**2)
x = np.linspace(0, 10, 100)
#part1
theta = 60
y0 = 1.0
v0= 15.0
y = ball(x, theta, v0, y0)
pl.plot(x, y)
#part2
theta = 60
y0 = 1.0
for v0 in range(10.0, 60.0, 10.0):
y2 = ball(x, theta, v0, y0)
pl.plot(x, y)
#part3
y0 = 1.0
for theta in range(0.0, 112.5, 22.5):
y3 = ball(x, theta, v0, y0)
pl.plot(x, y)
pl.plot(x, y, "r*")
pl.plot(x, y2, "bo")
pl.plot(x, y3, "y^")
pl.xlabel("X")
pl.ylabel("Y")
pl.legend(["x,y","x,y","x,y"])
pl.show()
please help me what is going on ??
range()function. Pass in integers instead.