from visual import *
k = 8.988e9
#Charge 1
c1 = sphere(pos=(0,0,0), radius=0.2,color=color.blue)
q1= -1e-9 #charge of Charge 1
#Charge 2
c2 = sphere(pos=(-0.5,-0.5,0), radius=0.2,color=color.red)
q2= 1e-9 #charge of charge 2
#charge3
c3 = sphere(pos=(0.5,-0.5,0), radius=0.2,color=color.yellow)
q3=1e-9 #charge of charge 3
#Observation Locations
#loc1
loc1= sphere(pos=(0,2,0), radius = 0.1,color=color.green)
rc1= mag(loc1.pos-c1.pos)
rc2= mag(loc1.pos-c2.pos)
rc3= mag(loc1.pos-c3.pos)
#rc4= mag(loc1.pos-c4.pos)
#rc5= mag(loc1.pos-c5.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vnet= Vc1 + Vc2 + Vc3
L1 = label(pos=loc1.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
#loc2
loc2= sphere(pos=(1.414,1.414,0), radius = 0.1,color=color.green)
rc1= mag(loc2.pos-c1.pos)
rc2= mag(loc2.pos-c2.pos)
rc3= mag(loc2.pos-c3.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vnet= Vc1 + Vc2 + Vc3
L2 = label(pos=loc2.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
#loc 3
loc3= sphere(pos=(2,0,0), radius = 0.1,color=color.green)
rc1= mag(loc3.pos-c1.pos)
rc2= mag(loc3.pos-c2.pos)
rc3= mag(loc3.pos-c3.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vnet= Vc1 + Vc2 + Vc3
L3 = label(pos=loc3.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
#loc4
loc4= sphere(pos=(1.414,-1.414,0), radius = 0.1,color=color.green)
rc1= mag(loc4.pos-c1.pos)
rc2= mag(loc4.pos-c2.pos)
rc3= mag(loc4.pos-c3.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vnet= Vc1 + Vc2 + Vc3
L4 = label(pos=loc4.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
#loc5
loc5= sphere(pos=(0,-2,0), radius = 0.1,color=color.green)
rc1= mag(loc5.pos-c1.pos)
rc2= mag(loc5.pos-c2.pos)
rc3= mag(loc5.pos-c3.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vnet= Vc1 + Vc2 + Vc3
L5 = label(pos=loc5.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
#loc6
loc6= sphere(pos=(-1.414,-1.414,0), radius = 0.1,color=color.green)
rc1= mag(loc6.pos-c1.pos)
rc2= mag(loc6.pos-c2.pos)
rc3= mag(loc6.pos-c3.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vnet= Vc1 + Vc2 + Vc3
L6 = label(pos=loc6.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
#loc7
loc7= sphere(pos=(-2,0,0), radius = 0.1,color=color.green)
rc1= mag(loc7.pos-c1.pos)
rc2= mag(loc7.pos-c2.pos)
rc3= mag(loc7.pos-c3.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vnet= Vc1 + Vc2 + Vc3
L7 = label(pos=loc7.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)
#loc8
loc8= sphere(pos=(-1.414,1.414,0), radius = 0.1,color=color.green)
rc1= mag(loc8.pos-c1.pos)
rc2= mag(loc8.pos-c2.pos)
rc3= mag(loc8.pos-c3.pos)
Vc1= k*q1/rc1
Vc2=k*q2/rc2
Vc3=k*q3/rc3
Vnet= Vc1 + Vc2 + Vc3
L8 = label(pos=loc8.pos,xoffset=20,yoffset=20,text= "V=%1.2f" % Vnet)