Add Current() and pull out special pens in ElectroMag.
authorW. Trevor King <wking@drexel.edu>
Fri, 27 May 2011 15:43:50 +0000 (11:43 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 27 May 2011 15:43:50 +0000 (11:43 -0400)
asymptote/ElectroMag-test.asy
asymptote/ElectroMag.asy

index c37c9cb2b792ba5d51aa1bc3caa5206c10e502a3..c2f5c0c5ca7271daaf8b2ab9811d0622bbd4f938 100644 (file)
@@ -51,5 +51,8 @@ Vector v = EField(a.center, mag=u/2, dir=0,L="E"); v.draw();
 Vector v = BField(a.center, mag=u/2, dir=90,L="B"); v.draw();
 Vector v = Velocity(a.center, mag=u/2, dir=180,L="$v$"); v.draw();
 
+Vector Ic = Current(center=(-0.7u, 2.2u), phi=90, L="$I$"); Ic.draw();
+draw(shift(Ic.center)*scale(16pt)*unitcircle, BFieldPen, ArcArrow);
+
 a = aCharge(center=(-3u, 2u), q=-1);
 a.draw();
index 7dd7b2e40689465460588e7d37d6a7ff8e26003d..2efcb9350531841aee227a5dbcb4edf906d98e40 100644 (file)
@@ -20,6 +20,7 @@
 import geometry;
 import Mechanics;
 
+
 // ---------------------- Charges -------------------------
 
 // charged particle
@@ -91,17 +92,27 @@ Charge aCharge(pair center=(0,0), real q=1, real radius=2mm, pen outline=current
 
 // ---------------------- Vectors -------------------------
 
+pen EFieldPen = rgb(1,0.5,0.2);    // orange
+pen BFieldPen = rgb(0.1,1,0.2);    // green
+pen CurrentPen = rgb(0.8,0.1,0.8); // purple
+
 // electric field
 Vector EField(pair center=(0,0), real mag=5mm, real dir=0, real phi=0, Label L="")
 {
-  Vector v = Vector(center=center, mag=mag, dir=dir, phi=phi, L=L, outline=rgb(1,0.5,0.2)); // orange
+  Vector v = Vector(center=center, mag=mag, dir=dir, phi=phi, L=L, outline=EFieldPen);
   return v;
 }
 
 // magnetic field
 Vector BField(pair center=(0,0), real mag=5mm, real dir=0, real phi=0, Label L="")
 {
-  Vector v = Vector(center=center, mag=mag, dir=dir, phi=phi, L=L, outline=rgb(0.1,1,0.2)); // green
+  Vector v = Vector(center=center, mag=mag, dir=dir, phi=phi, L=L, outline=BFieldPen);
+  return v;
+}
+
+Vector Current(pair center=(0,0), real mag=5mm, real dir=0, real phi=0, Label L="")
+{
+  Vector v = Vector(center=center, mag=mag, dir=dir, phi=phi, L=L, outline=CurrentPen);
   return v;
 }