Samstag, 24. April 2010
Python 045 Lorentz force
import time
from visual import *
# lorentzkraft
scene.title="..."
scene.width=600
scene.height=600
scene.autoscale = 0
scene.forward = (-1,-.5,-1)
R = 0.1
avector = [2,1,2]
bvector = [1,0,0]
cvector = cross(avector,bvector)
a = arrow(pos=(0,0,0), axis=avector, shaftwidth=R, color=color.white)
b = arrow(pos=(0,0,0), axis=bvector, shaftwidth=R, color=crayola.green)
c = arrow(pos=(0,0,0), axis=cvector, shaftwidth=R, color=crayola.yellow)
alabel=label(pos=avector, text="dl", yoffset=-5, opacity=0, box=0, line=0)
blabel=label(pos=bvector, text="B", yoffset=-5, opacity=0, box=0, line=0)
clabel=label(pos=cvector, text="F", yoffset=-5, opacity=0, box=0, line=0)
line1 = sphere(radius=0.01)
line1.trail = curve()
line2 = sphere(radius=0.01)
line2.trail = curve()
size = .1
for n in range(3000):
avectorold = avector
cvectorold = cvector
avector[0] = sin(n/10.0*size)
a.axis.x = avector[0]
avector[1] = sin(n/10.0*size*1.83)
a.axis.y = avector[1]
avector[2] = sin(n/10.0*size*1.33)
a.axis.z = avector[2]
cvector = cross(avector,bvector)
c.axis = cvector
#LABEL
alabel.pos = avector
blabel.pos = bvector
clabel.pos = cvector
alabel.text = "dl: " + str(avector)
blabel.text = "B: " + str(bvector)
clabel.text = "F: " + str(cvector)
#TRAIL
line1.trail.append(pos=avector)
line2.trail.append(pos=cvector, color=color.yellow)
time.sleep(0.1)
Abonnieren
Kommentare zum Post (Atom)
1 Kommentar:
good work kame!
Kommentar veröffentlichen