import math


def ballistic(v0=50., angle=45., x0=0., y0=0., dt = .01, cD=.47, A=.8, m=3.):
    """
    Ballisitic function with drag
    gets parameters (floats):
    speed, angle, intitial posiiton, time step, drag coefficient, Area, mass
    If you want no drag, pass cD=.0
    return arrays of the Y and X position
    """
    g = -9.81
    rho = 1.225
    xTab = []
    yTab = []
    vx = v0*math.cos(math.radians(angle))
    vy = v0*math.sin(math.radians(angle))
    x = x0
    y = y0
    while y>=y0:
        phi = math.atan2(vy,vx)
        D = cD*A*.5*rho*(vx*vx+vy*vy)
        ax = -D*math.cos(phi)/m
        vx += ax*dt
        x += vx*dt
        ay = g-D*math.sin(phi)/m
        vy += ay*dt
        y += vy*dt
        xTab.append(x)
        yTab.append(y)
    return xTab, yTab