summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/trajectoryline.mp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-12-03 16:47:39 +0000
committerKarl Berry <karl@freefriends.org>2011-12-03 16:47:39 +0000
commit97e4684a37e4899e8cdd42ab670b6e25dd319d1a (patch)
treebc263a56d75c177b79ae13c6e6ec7a3c30278dbf /Master/texmf-dist/doc/metapost/featpost/example/trajectoryline.mp
parenta2c8654f8955a0d35c8b0c2d1752a506a426681b (diff)
featpost (17nov11)
git-svn-id: svn://tug.org/texlive/trunk@24738 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/metapost/featpost/example/trajectoryline.mp')
-rw-r--r--Master/texmf-dist/doc/metapost/featpost/example/trajectoryline.mp88
1 files changed, 88 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/metapost/featpost/example/trajectoryline.mp b/Master/texmf-dist/doc/metapost/featpost/example/trajectoryline.mp
new file mode 100644
index 00000000000..182fa6d77a6
--- /dev/null
+++ b/Master/texmf-dist/doc/metapost/featpost/example/trajectoryline.mp
@@ -0,0 +1,88 @@
+% trajectoryline.mp
+% L. Nobre G.
+% 2003
+
+input featpost3Dplus2D;
+
+Spread := 30;
+f := (10,0,0);
+
+color posa, posb, axer;
+numeric kfac, refrad;
+posa = -5*green;
+posb = 5*green;
+axer = blue;
+kfac = 2.5;
+refrad = 1;
+
+def vecfunc( expr posit )=
+ begingroup
+ save modula, modulb, field;
+ color field;
+ numeric modula, modulb;
+ modula = conorm( posit-posa );
+ modulb = conorm( posit-posb );
+ field = ( posit-posa )/(modula**3)+kfac*( posit-posb )/(modulb**3);
+ ( -field )
+ endgroup
+enddef;
+
+def magfunc( expr posit )=
+ begingroup
+ save perpd, refvec, dist;
+ color perpd, refvec;
+ numeric dist;
+ perpd = ccrossprod( axer, posit );
+ refvec = posit - refrad*ncrossprod( perpd, axer );
+ dist = conorm( refvec );
+ ( ncrossprod( refvec, perpd )/(dist**2) )
+ endgroup
+enddef;
+
+beginfig(1);
+ numeric i, lena, numa, sa, diffstep, ray;
+ color stp, svl;
+ path oneline;
+ pen grossa, fina;
+ grossa = pencircle scaled 3pt;
+ fina = pencircle scaled 2pt;
+ lena = 400;
+ numa = 58;
+ diffstep = 0.12;
+ ray = 3.5;
+ sa = 168;
+ for i=sa step numa until (180):
+ stp := ( 0, ray*cosd(i), ray*sind(i) );
+ svl := N( -stp );
+ oneline := trajectorypath( lena, stp, svl, diffstep, vecfunc );
+ draw oneline withpen grossa;
+ draw oneline withpen fina withcolor background;
+ endfor;
+ draw rp(posa) withpen grossa;
+ draw rp(posb) withpen grossa;
+endfig;
+
+beginfig(2);
+ numeric i, lena, numa, sa, diffstep, ray;
+ color stp, svl;
+ path oneline;
+ pen grossa, fina;
+ grossa = pencircle scaled 3pt;
+ fina = pencircle scaled 2pt;
+ lena = 100;
+ numa = 4;
+ diffstep = 1;
+ ray = 5.5;
+ sa = 97;
+ for i=sa step numa until (120):
+ stp := ( 0, ray*cosd(i), ray*sind(i) );
+ svl := 0.8*N( -stp );
+ oneline := magnetictrajectorypath( lena, stp, svl, diffstep, magfunc );
+ draw oneline withpen grossa;
+ draw oneline withpen fina withcolor background;
+ endfor;
+ draw rp(black) withpen grossa;
+endfig;
+
+end.
+