summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/repeated/nembends.mp
blob: 5900e88d187c5747aea5d34151945290c9ea1c47 (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
% nembends.mp
% L. Nobre G.
% 2002

%input featpost3Dplus2D;

%input mp-tool;

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

	numeric hsdev, basestep, basxstep, basesdev;
	numeric i, j, k, coesdev, cylength, cyradius, basen;
	numeric vcx, vcy, vcz, hcurr, xcurr, ycurr, aone;
	numeric atwo, zcurr, coestep, angsdev, basxsdev;
	color lenvec, currpos;


	coestep    := -0.15; 
	cylength   := 0.6;
	cyradius   := 0.1;
	basen	   := 3;
	basestep   := cylength*1.6;
	basxstep   := cyradius*4;
	basesdev   := basestep*0.001;
	basxsdev   := basxstep*0.001;
	hsdev	   := 0.005;
	coesdev	   := 0.001;
	angsdev    := 0.02;
	for i=-basen upto basen:
	    for j=-basen upto basen:
		    xcurr   :=        i*basxstep + basxsdev*normaldeviate;
		    ycurr   :=        j*basestep + basesdev*normaldeviate;
		    zcurr   :=   ycurr**2*coestep + coesdev*normaldeviate;
		    aone    :=                      angsdev*normaldeviate;
		    atwo :=angle(1,ycurr*2*coestep)+angsdev*normaldeviate;
		    vcz     := cosd( aone )*sind( atwo );
		    vcy     := cosd( aone )*cosd( atwo ); 
		    vcx     := sind( aone ); 
		    currpos := ( xcurr, ycurr, zcurr );
		    lenvec  := cylength*( vcx, vcy, vcz ); 
		    rigorousdisc(0,true,currpos-0.5*lenvec,cyradius,lenvec);
	    endfor;
	endfor;
endfig;

end;