Hi, i’m still working on this script but actually i’m stuck by a lack of physics knowledge. I’m trying to represent the multipole electric field from two lists: one for the electric field (‘pointsgrid’) and one for the charges (‘cpointlist’). The ‘pointsgridlist’ contains a list of coordinates [x,y,z] and the ‘cpointlist’ contains a list of Blender objects with their charges sign (positive = 1, negative = 0) as following:
pointsgridlist = [[x,y,z],[x,y,z],[x,y,z],[x,y,z],…]
cpointlist = [[Object,sign],[Object,sign],[Object,sign],[Object,sign],…]
for each points of pointsgridlist the script calculates the sum of the field in X, Y and Z coordinates and then dram a mesh line from the point to the new X,Y,Z coordinates.
Its returning a really strange result, every lines are oriented to the center of pointsgridlist and their length is incredibly huge.:eek:
here is the code:
for points in pointsgrid:
X = 0
Y = 0
Z = 0
for cpoints in cpointlist:
if cpoints[1] == 1:
Q = 1
else:
Q = -1
EX = (Q/(4*math.pi*(8.8542/1000000000000)))*\
(points[0]-cpoints[0].getLocation()[0]/\
(((points[0]-cpoints[0].getLocation()[0])**2)**(3/2)))
EY = (Q/(4*math.pi*(8.8542/1000000000000)))*\
(points[1]-cpoints[0].getLocation()[1]/\
(((points[1]-cpoints[0].getLocation()[1])**2)**(3/2)))
EZ = (Q/(4*math.pi*(8.8542/1000000000000)))*\
(points[2]-cpoints[0].getLocation()[2]/\
(((points[2]-cpoints[0].getLocation()[2])**2)**(3/2)))
X += EX
Y += EY
Z += EZ
vob = Object.New('Mesh','VectorField')
me = Mesh.New('VecLine')
coords = [[points[0],points[1],points[2]],[X,Y,Z]]
me.verts.extend(coords)
me.edges.extend(me.verts[0],me.verts[1])
vob.link(me)
scn = Scene.GetCurrent()
scn.objects.link(vob)
vob.layers = [2]
Redraw()
Anybody good with physics?
I really hope to fix that