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();
import geometry;
import Mechanics;
+
// ---------------------- Charges -------------------------
// charged particle
// ---------------------- 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;
}