
#Physics calculator projectile motion how to#
So I guess another request is an explanation of how to obtain the set of equations (position, velocity, acceleration) for the x direction based on whether the wind angle is helpful or hurtful, and how to obtain the set of equations for the y direction, based again on whether the wind is helpful or hurtful. Oh, and in the scenario of the wind, it can blow from any angle, which means it will affect the x and y velocities and either augment them or lessen them depending on the angle at which it blows. The reason I want to know this is that I am writing a program to model this behavior, but I first need to know these equations.Īlso, if possible, could someone provide some help on finding equations for the maximum height the projectile reaches, as well as the distance it travels before it hits the ground? I would like both of these to be values the user of the program can find if desired. In essence, what I would like to know is how to rewrite the kinematics equations to take into account the air resistance and moving wind and the terminal velocity. If an object were fired out of a cannon, or some sort of launcher, so that it had both an initial velocity and an initial angle, and air resistance is taken into account, what would be the equations for the x and y components of the position, velocity, and acceleration.įurthermore, I am wondering how these equations would change if there were also a wind blowing at an angle. By multiplying a row vector and a column vector, array broadcasting ensures that the resulting matrix behaves the way we want it (i.e.I am wondering how the general kinematics equations would change in the following situation. I also used and to turn 1d numpy arrays to 2d row and column vectors, respectively.

I made use of the fact that plt.plot will plot the columns of two matrix inputs versus each other, so no loop over angles is necessary. Plt.plot(x,y) #plot each dataset: columns of x and columns of y Timemat = tmax*np.linspace(0,1,100) #create time vectors for each angle Theta = np.arange(25,65,5)/180.0*np.pi #convert to radians, watch out for modulo division G = 9.81 #improved g to standard precision, set it to positive So here's what I'd do: import numpy as np Unless you set the y axis to point downwards, but the word "projectile" makes me think this is not the case. This assumes that g is positive, which is again wrong in your code.

Lastly, you need to use the same plotting time vector in both terms of y, since that's the solution to your mechanics problem: y(t) = v_*t - g/2*t^2 This is not what you need: you need to compute the maximum time t for every angle (which you did in t), then for each angle create a time vector from 0 to t for plotting!
#Physics calculator projectile motion code#
Thirdly, your current code sets t1 to have a single time point for every angle. You have to convert your angles to radians before passing them to the trigonometric functions. Secondly, your angles are in degrees, but math functions by default expect radians. P = # Don't fall through the floorįirstly, less of a mistake, but matplotlib.pylab is supposedly used to access matplotlib.pyplot and numpy together (for a more matlab-like experience), I think it's more suggested to use matplotlib.pyplot as plt in scripts (see also this Q&A). X = ((v*k)*np.cos(i)) # get positions at every point in time T = np.linspace(0, 5, num=100) # Set time as 'continous' parameter.įor i in theta: # Calculate trajectory for every angle

#increment theta 25 to 60 then find t, x, y One more thing: Angles can't just be written as 60, 45, etc, python needs something else in order to work, so you need to write them in numerical terms, (0,90) = (0,pi/2).

So time is continuous parameter! You don't need the time of flight. Initial is important! That's the time when we start our experiment. Initial velocity and angle, right? The question is: find the position of the particle after some time given that initial velocity is v=something and theta=something. What do you need to know in order to get the trajectory of a particle? You know this already, but lets take a second and discuss something. First of all g is positive! After fixing that, let's see some equations:
