summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/repeated/nemdirector.mp
blob: 4c1d88fe09515f635fc34096dbf7c2e952784cab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
% nemdirector.mp
% L. Nobre G.
% 2003

%input featpost3Dplus2D;

verbatimtex 
\documentclass{article} 
%\usepackage{mathpazo} 
\begin{document} 
etex

beginfig(1);
	f := 2*(5,3,4);
	Spread := 70;

	numeric cylength, cyradius, zoneradi, zoneleng;
	numeric i, angsdev, halfnum, directlen, arrthick;
	numeric vcx, vcy, vcz, xcurr, ycurr, thickfact;
	numeric atwo, zcurr, aone, apos;
	color lenvec, currpos, tippos;
	path arrpath;
	picture tmppict;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Nu
	cylength   := 0.45;
	cyradius   := 0.1;
	zoneradi   := 2;
	zoneleng   := 4;
	directlen  := 5.6;
	angsdev	   := 12;
	halfnum    := 130;
	thickfact  := 5;
	arrthick   := Spread*ps( (0,0,0), thickfact );
	tippos     := (0,0,0.5*directlen);
	arrpath    := rp(-tippos)--rp(tippos);
	ahlength   := 3*arrthick;
	ahangle    := 40;
	for i=1 upto halfnum:
	  zcurr   := -0.5*zoneleng+uniformdeviate( zoneleng );
	  apos    := uniformdeviate( 180 );
	  xcurr   := -zoneradi*cosd( apos )*uniformdeviate( 1 );
	  ycurr   := zoneradi*sind( apos )*uniformdeviate( 1 );
	  aone    := uniformdeviate( 360 );
	  atwo    := angsdev*normaldeviate;
	  vcz     := cosd( atwo );
	  vcy     := sind( atwo )*sind( aone );
	  vcx     := sind( atwo )*cosd( aone );
	  currpos := ( xcurr, ycurr, zcurr );
	  lenvec  := cylength*( vcx, vcy, vcz ); 
	  generatedirline( i, aone, 90-atwo, cylength, currpos );
	endfor;
	NL:= halfnum;
	director_invisible( true, thickfact, false );
	drawarrow arrpath withpen pencircle scaled arrthick;
	for i=1 upto halfnum:
	  zcurr   := -0.5*zoneleng+uniformdeviate( zoneleng );
	  apos    := uniformdeviate( 180 );
	  xcurr   := zoneradi*cosd( apos )*uniformdeviate( 1 );
	  ycurr   := zoneradi*sind( apos )*uniformdeviate( 1 );
	  aone    := uniformdeviate( 360 );
	  atwo    := angsdev*normaldeviate;
	  vcz     := cosd( atwo );
	  vcy     := sind( atwo )*sind( aone );
	  vcx     := sind( atwo )*cosd( aone );
	  currpos := ( xcurr, ycurr, zcurr );
	  lenvec  := cylength*( vcx, vcy, vcz ); 
	  generatedirline( i, aone, 90-atwo, cylength, currpos );
	endfor;
	NL:= halfnum;
	director_invisible( true, thickfact, false );
	label.ulft(btex $\vec{n}$ etex scaled 8.5 rotated 90, rp(tippos) );
	tmppict := currentpicture rotated -90;
	currentpicture := nullpicture;
	draw tmppict;
endfig;

verbatimtex
\end{document}
etex

end;