Skip to content
Extraits de code Groupes Projets
ex5_sol2.py 900 octets
Newer Older
  • Learn to ignore specific revisions
  • Martin Delcourt's avatar
    Martin Delcourt a validé
    import math
    
    v0    = float(input("Vitesse initiale ?"))
    alpha = float(input("Angle initial ?"))
    
    v0_x = v0*math.cos(alpha*math.pi/180)
    v0_y = v0*math.sin(alpha*math.pi/180)
    g = 9.81
    
    
    n_lines = 50
    n_col   = 100
    
    print(" "+n_col*"-")
    lineId = 0
    while lineId < n_lines:
        colId = 0
        txt_to_print = "|"
        while colId < n_col:
            t = 0
            filled = False
            while t < 10000:  # On évalue toute la trajectoire pour chaque case du tableau...
                x = v0_x*t
                y = v0_y*t - 0.5*g*t**2
                t+=0.01
                if abs(x - colId ) < 0.5 and abs(n_lines-y-lineId)<0.5:
                    txt_to_print+="x"
                    filled = True
                    break
                if y < 0 or x < 0 or x > n_col:
                    break
            if filled == False:
                txt_to_print += " "
    
            colId+=1
    
        lineId+=1
    
    fbury's avatar
    fbury a validé
        print (txt_to_print+"|")
    
    Martin Delcourt's avatar
    Martin Delcourt a validé
    print(" "+n_col*"-")