2 Determine the initial direction of the deflection of charged particles
3 as they enter the magnetic fields shown in Figure~P29.2.
17 int n = (int)(width / dx);
18 int m = (int)(height / dy);
19 real xstart = -width/2 + (dx+fmod(width,dx))/2.0;
20 real ystart = -height/2 + (dy+fmod(height,dy))/2.0;
21 for (int i=0; i<n; i+=1) {
22 for (int j=0; j<m; j+=1) {
23 Bs.push(BField((xstart+i*dx, ystart+j*dy), phi=-90));
26 for (int i=0; i<Bs.length; i+=1) {
30 Charge a = pCharge((-0.5*width-12pt, 0), "$+$");
31 Vector v = Velocity(a.center, dir=0);
35 label("\Part{a}", (0,0.5*height), N);
48 int n = (int)(width / dx);
49 real xstart = -width/2 + (dx+fmod(width,dx))/2.0;
50 real ystart = -height/2;
51 for (int i=0; i<n; i+=1) {
52 Bs.push(BField((xstart+i*dx, -height/2), mag=height, dir=90));
54 for (int i=0; i<Bs.length; i+=1) {
58 Charge a = nCharge((0.5*width+12pt, 0), "$-$");
59 Vector v = Velocity(a.center, dir=180);
63 label("\Part{b}", (0,0.5*height), N);
77 int m = (int)(height / dy);
78 real xstart = -width/2;
79 real ystart = -height/2 + (dy+fmod(width,dy))/2.0;
80 for (int i=0; i<m; i+=1) {
81 Bs.push(BField((-width/2,ystart+i*dy), mag=width, dir=0));
83 for (int i=0; i<Bs.length; i+=1) {
87 Charge a = pCharge((0.5*width+12pt, 0), "$+$");
88 Vector v = Velocity(a.center, dir=180);
92 label("\Part{c}", (0,0.5*height), N);
106 int n = (int)(width / dx);
107 int m = (int)(height / dy);
108 real xstart = -width/2 + (dy+fmod(width,dx))/2.0;
109 real ystart = -height/2 + (dy+fmod(width,dy))/2.0;
110 for (int i=0; i<n; i+=1) {
111 Bs.push(BField((xstart,ystart+i*dy), mag=sqrt(2)*(height/2-(ystart+i*dy)), dir=45));
113 for (int i=0; i<m; i+=1) {
114 Bs.push(BField((xstart+i*dx,ystart), mag=sqrt(2)*(width/2-(xstart+i*dx)), dir=45));
116 for (int i=0; i<Bs.length; i+=1) {
120 draw((0, -height/2)--(0, height/2), dashed);
121 Angle t = Angle(dir(90)-(0,dy), (0,0)-(0,dy), dir(45)-(0,dy), "$\theta=45\dg$");
124 Charge a = pCharge((0, -0.5*height-12pt), "$+$");
125 Vector v = Velocity(a.center, dir=90);
129 label("\Part{d}", (0,0.5*height), N);