/* * fele.java - revised 9 Jan 08 - width 401, height 201 * @author jackord@kw.igs.net * motion of electrons in a field with cylindrical symmetry * field set up by conducting plates in the x-z plane with a narrow gap * between them - positive (attractive) plate in the left half-plane * - negative (repulsive) plate in the right half-plane * the source emits monoenergetic electrons in the x-y plane */ import java.applet.Applet; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class fele extends Applet implements ActionListener { int kk=0; String bs="Plot"; Button b=new Button(bs); public void init() { setLayout(new FlowLayout(FlowLayout.LEFT)); add(b); b.addActionListener(this); setBackground(new Color(211, 211, 211)); // Light Gray Background } public void paint(Graphics g) { double dt, x, y, vx, vy, r2, vo, phi; int x1, y1, x2, y2, del; g.setColor(Color.black); g.drawRect(0, 0, 400, 200); g.setColor(Color.magenta); g.drawLine(0, 200, 200, 200); g.setColor(Color.green); g.drawLine(200, 200, 400, 200); g.setColor(Color.darkGray); for (int i=40; i<=160; i=i+40) { // Field lines g.drawArc(200-i, 200-i, 2*i, 2*i, 0, 180); } g.setColor(Color.red); g.fillArc(300-5, 100-5, 10, 10, 0, 360); g.setColor(Color.blue); vo=Math.sqrt(Math.PI/2); dt=1; if (kk==1) { long tt=System.currentTimeMillis(); del=5; for (int jt=0; jt<=11; jt=jt+1) { // Angle loop phi=Math.PI*jt/6; vx=vo*Math.cos(phi); vy=vo*Math.sin(phi); x=100; y=100; r2=x*x+y*y; x1=200+(int)(x); y1=200-(int)(y); vx=vx-y/r2*dt/2; vy=vy+x/r2*dt/2; // Half-step do { // Feynman loop x=x+vx*dt; y=y+vy*dt; x2=200+(int)(x); y2=200-(int)(y); g.drawLine(x1, y1, x2, y2); x1=x2; y1=y2; r2=x*x+y*y; vx=vx-y/r2*dt; vy=vy+x/r2*dt; tt=tt+del; while (tt>System.currentTimeMillis()) { } } while ((x1>0)&&(x1<400)&&(y1>0)&&(y1<200)&&(kk>0)); } kk=0; } } public void actionPerformed(ActionEvent e) { // Plot button String tst; tst=e.getActionCommand(); if (bs.equals(tst)) { kk=1; repaint(); } } }