summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/lcurvature.mp
blob: 14fc30e7752d868e9ee4846ea6f79f12ae0f83b2 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
% lcurvature.mp
% L. Nobre G.
% 2002

input featpost3Dplus2D;

verbatimtex 
\documentclass{article} 
\usepackage{beton} 
\usepackage{concmath} 
\usepackage{ccfonts} 
\begin{document} 
etex

beginfig(1);
	f := (5,3,4);
	Spread := 70;
	numeric gridstep, anglstep, cylength, cyradius, numcylis;
	numeric i, j, curcoord, vcx, vcy, vcz, curangle, curnorma;
	numeric major, othcoord, othangle;
	color base, lenvec;
	cylength := 0.1;
	cyradius := 0.3;
	gridstep := cyradius*2.2;
	anglstep := 10;
	numcylis := 5;
	major := 0.35*gridstep*numcylis;
	for i=1 upto numcylis:			% bend
		curnorma := i-0.5*(numcylis+1);
		curangle := curnorma*anglstep;
		vcx := cylength*cosd(curangle);
		vcy := 0;	
		vcz := cylength*sind(curangle);	
		base := major*(sind(curangle),-1,-cosd(curangle));
		lenvec := (vcx,vcy,vcz);
		rigorousdisc( 0, true,base,cyradius,lenvec);
	endfor;
	for i=1 upto numcylis:			% twist
		curnorma := i-0.5*(numcylis+1);
		curcoord := curnorma*gridstep;
		curangle := curnorma*anglstep;
		vcx := 0;
		vcy := cylength*sind(curangle);	
		vcz := cylength*cosd(curangle);	
		base := (curcoord,-vcy/2-major,-vcz/2+major);
		lenvec := (vcx,vcy,vcz);
		rigorousdisc( 0, true,base,cyradius,lenvec);
	endfor;
	for i=1 upto numcylis:			% splay
		curnorma := i-0.5*(numcylis+1);
		curcoord := curnorma*gridstep;
		curangle := curnorma*anglstep;
		vcx := cylength*sind(curangle);
		vcy := 0;	
		vcz := -cylength*cosd(curangle);	
		lenvec := (vcx,vcy,vcz);
		for j=1 upto numcylis:
			othcoord := (j-0.5*(numcylis+1))*gridstep;
			base := major*(0,1,-cosd(curangle));
			base := base +(curcoord,othcoord,0);
			rigorousdisc( 0, true,base,cyradius,lenvec);
		endfor;
	endfor;
	for i=1 upto numcylis:			% saddle
		curnorma := i-0.5*(numcylis+1);
		curcoord := curnorma*gridstep;
		curangle := curnorma*anglstep;
		vcx := cylength*sind(curangle);
		for j=1 upto numcylis:
			othcoord := (j-0.5*(numcylis+1))*gridstep;
			othangle := (j-0.5*(numcylis+1))*anglstep;
			vcy := -cylength*sind(othangle);	
			vcz := -cylength*cosd(curangle)*cosd(othangle);	
			base := major*(0,1,1-cosd(curangle)+cosd(othangle));
			base := base + (curcoord,othcoord,0);
			lenvec := (vcx,vcy,vcz);
			rigorousdisc( 0, true,base,cyradius,lenvec);
		endfor;
	endfor;
endfig;

beginfig(2);
	f := (5,3,4);
	Spread := 70;
	numeric gridstep, cylength, cyradius, numcylis;
	numeric i, j, curcoord, curangle, curnorma;
	numeric othcoord, othangle, zcoord, coef, othnorma;
	color base, lenvec;
	cylength := 0.1;
	cyradius := 0.3;
	gridstep := cyradius*2.2;
	numcylis := 5;
	coef := 0.32;
	for i=1 upto numcylis:			% splay
	    curnorma := i-0.5*(numcylis+1);
	    curcoord := curnorma*gridstep;
	    curangle := -curcoord*2*coef;
	    for j=1 upto numcylis:
		othnorma := j-0.5*(numcylis+1);
		othcoord := othnorma*gridstep;
		othangle := -othcoord*2*coef;
		zcoord := -coef*(othcoord**2+curcoord**2);
		base := (curcoord,othcoord,zcoord);
		lenvec := cylength*N((-curangle,-othangle,1));
		rigorousdisc( 0, true,base,cyradius,lenvec);
	    endfor;
	endfor;
endfig;

verbatimtex 
\end{document} 
etex

end;