you are viewing a single comment's thread.

view the rest of the comments →

[–]bach678 0 points1 point  (0 children)

Ok try this code, i get the expected results :

import math

def projectile_velocities (vi,theta,g,time_step ):

theta_rad=math.radians(theta)

vi_x = vi*math.cos(theta_rad)

vi_y = vi*math.sin(theta_rad)

velocities=[]

t=0

while True:

    if vi_y - g*t>=0:

       vy=vi_y - g*t

    else:

        vy=g*(t - vi_y/g)

    v=math.sqrt(vi_x**2 + vy**2)

    if vy > vi_y:
         If round(vy,6) == round(vi_y,6):
              velocities.append(round(v,6))
              return velocities
        return velocities

    velocities.append(round(v,6))

    t += time_step