Fix x position of last solution segment in Serway and Jewett v8's 25.36.
[course.git] / asymptote / ElectroMag-test.asy
1 /* Test suite for ElectroMag.asy.
2  *
3  * Copyright (C) 2008-2009 W. Trevor King <wking@drexel.edu>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19
20 import ElectroMag;
21
22 real u = 1cm;
23
24 Charge a = pCharge(center=(0.5u,2u));
25 Charge b = aCharge(center=(0,-0.5u), q=1);
26 Charge c = nCharge(center=(-3u,-0.5u), q=-3);
27 Charge cs[] = {a,b,c};
28 string subscripts[] = {"a"};
29 Distance dab = Distance(b.center(), a.center(), scale=u, L="$r_1$");
30 Distance dbc = Distance(c.center(), b.center(), scale=u, L="$r_2$");
31 Distance ds[] = {dab};
32 Angle abc = Angle(
33     a.center(), b.center(), c.center(), radius=.5u, L="$\theta_T$");
34 Angle bac = Angle(
35     b.center(), a.center(), c.center(), radius=-0.4u, L="$\phi_x$");
36 Angle as[] = {abc, bac};
37
38 //write(a.center.x);
39 //write(a.center.y);
40 for (int i=0; i<cs.length; i+=1)
41   cs[i].draw();
42 for (int i=0; i<ds.length; i+=1)
43   ds[i].draw();
44 for (int i=0; i<as.length; i+=1)
45   as[i].draw();
46
47 CoulombEFields((-0.5u, 1.2u), c=cs, subscripts=subscripts, scale=2u, unit=u/2);
48 //Vector Fba = CoulombForce(b,a, scale=2u, unit=u);
49 //Fba.draw();
50 CoulombForces(c=cs, subscripts=subscripts, scale=2u, unit=u);
51
52 Charge a = aCharge(center=(-2u, 2u), q=0);
53 a.draw();
54 Vector v = EField(a.center(), mag=u/2, dir=0,L="E"); v.draw();
55 Vector v = BField(a.center(), mag=u/2, dir=90,L="B"); v.draw();
56 Vector v = Velocity(a.center(), mag=u/2, dir=180,L="$v$"); v.draw();
57
58 Vector Ic = Current(center=(-0.7u, 2.2u), phi=90, L="$I$"); Ic.draw();
59 draw(shift(Ic.center)*scale(16pt)*unitcircle, BFieldPen, ArcArrow);
60
61 a = aCharge(center=(-3u, 2u), q=-1);
62 a.draw();