import numpy as np

def pointPotential(x,y,q,posx,posy):
    """ evaluates the potential for a single point charge
    """
    k = 8.929*10**9
    Vxy = (k*q)/np.sqrt((x-posx)**2+(y-posy)**2)
    return Vxy

def dipolePotential(x,y,q,d):
    """returns the potential for a dipole centered at (0,0) with the charges on the x-axis seperated by a distance 2d
    """
    posx1 = d
    posx2 = -d
    posy = 0
    Vxy = pointPotential(x,y,q,posx1,posy) - pointPotential(x,y,q,posx2,posy)
    return Vxy

def pointField(x,y,q,Xq,Yq):
    """returns a tuple of the lectric field components (Ex,Ey)
    """
    k=9*10**9
    Ex= (k*q*(x-Xq))/((((x-Xq)**2+(y-Yq)**2))**0.5)
    Ey= (k*q*(y-Yq))/((((x-Xq)**2+(y-Yq)**2))**0.5)
    return Ex
    return Ey
    
