/usr/share/doc/python-visual/examples/dipole.py is in python-visual 1:5.12-1.6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | from visual import *
print """
Click to plot a normalized electric field vector.
Vectors are blue if low magnitude, red if high.
Right button drag to rotate camera to view scene.
On a one-button mouse, right is Command + mouse.
Middle button drag up or down to zoom in or out.
On a two-button mouse, middle is left + right.
On a one-button mouse, middle is Option + mouse.
"""
ec = 1.6e-19 # electron charge
scene.title="Electric Field Vectors"
scene.range = 2e-13
charges = [ sphere( pos = (-1e-13,0,0), Q = ec, color=color.red, radius = 6e-15 ),
sphere( pos = ( 1e-13,0,0), Q = -ec, color=color.blue, radius = 6e-15 ),
]
def getfield(p):
f = vector(0,0,0)
for c in charges:
f = f + (p-c.pos) * 8.988e9 * c.Q / mag(p-c.pos)**3
return f
while 1:
p = scene.mouse.getclick().pos
f = getfield(p)
m = mag(f)
red = maximum( 1-1e17/m, 0 )
blue = minimum( 1e17/m, 1 )
if red >= blue:
blue = blue/red
red = 1.0
else:
red = red/blue
blue = 1.0
arrow( pos=p, axis=f * (4e-14/1e17),
shaftwidth = 6e-15,
color=(red,0,blue))
|