Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find projectile angle from distance python

def traj_fr(angle, v0):             #function that computes trajectory for some launch angle & velocity
    vx0 = math.cos(angle)*v0        #compute x components of starting velocity
    vy0 = math.sin(angle)*v0        #compute y components of starting velocity
    x = np.zeros(len(time))         #initialise x array
    y = np.zeros(len(time))         #initialise y array
  
    x[0],y[0] = 0,0     #initial position at t=0s, ie motion starts at (0,0)
    x[1],y[1] = x[0] + vx0*(2*dt), y[0]+vy0*(2*dt)  #calculating 2nd elements of x & y based on init velocity
  
    i=1
    while y[i]>=0:  #loop continuous until y becomes <0, ie projectile hits ground
        f = 0.5 * gamm * (h - y[i]) * dt        #intermediate 'function'; used in calculating x & y vals below
        x[i+1] = ((2*x[i]-x[i-1]) + (f * x[i-1])) / (1 + f)                 #numerical integration to find x[i+1]...
        y[i+1] = ((2*y[i]-y[i-1]) + (f * y[i-1]) - g*(dt**2) ) / (1 + f)      # ...& y[i+1]
        i = i+1     #increment i for next iteration
  
    x = x[0:i+1]        #truncate x array
    y = y[0:i+1]        #truncate y array
    return x, y, (dt*i), x[i]       #return x, y, flight time, range of projectile
Comment

PREVIOUS NEXT
Code Example
Python :: how to export schema in graphene django 
Python :: how to make an infinite loop in python 
Python :: how to register button presses in pysimpleGUI 
Python :: how to search over a notebook in python 
Python :: how to see if something is in a class in python 
Python :: hello world with a variable in python 3 
Python :: pyglet on close 
Python :: run exe for python and wait until finish 
Python :: Lcd screen 3.5 inch to pi 
Python :: python list three from the back 
Python :: first n lis tpython 
Python :: read file in python 
Python :: leetcode 206 python 
Python :: the entire bee movie script but backwards 
Python :: pandas plot column titles vertical 
Python :: python setattr function 
Python :: uneven chunks of array slices 
Python :: re mobile no validate python 
Python :: pybind11 python37_d.dll access violation 
Python :: geopandas nan to 0 
Python :: python three periods 
Python :: violajones python opencv 
Python :: aes in django 
Python :: python redirect console output to devnull 
Python :: tkl to pkr 
Python :: get user id discord.py 
Python :: rename a column 
Python :: python array sum 
Python :: scikit decision tree regressor 
Python :: add key to dictionary python 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =