Cara menemukan sudut proyektil dari python jarak
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
Rich Rook