summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/highmemory/par3Dplotexamples.mp
blob: 6b05682918a3dc7bc985ccbac4f9d6580d707325 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
% J. Schwaiger with help of
% FEATPOST and the macropackages
% la3Dmacros.mp and hlr3Dmacros.mp
% by L. Nobre G.
% 2003

% Figure (2) retouched in 2004 by L. Nobre G.

verbatimtex
\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{euler}
\usepackage{graphicx}
\begin{document}
etex

% for trigonometric functions when angles are measured in rad
%    
    def sinrad( expr t)=sind(t/3.145*180) enddef;
    def cosrad( expr t)=cosd(t/3.145*180) enddef;

    def parsurface( expr tc,sc )=
      (%
	(4 cosrad(tc) - sinrad(sc)*cosrad(tc),%
	  4 sinrad(tc) - sinrad(sc)*sinrad(tc),%
	  cosrad(sc))%
	)% A torus
    enddef;

    def parsurfacetwo( expr tc,sc )=
      (%
	(4+4cosrad(tc) - sinrad(sc)*cosrad(tc),%
	  cosrad(sc),
	  4sinrad(tc) - sinrad(sc)*sinrad(tc)%
	  )%
	)% Another torus
    enddef;

    def parsurfacethree( expr tc,sc )=
% 0<=sc<=2pi,-2<=tc<=2
%xmin=-1.4, xmax=1.4
%ymin=-0.7, ymax=2
%zmin=-2.5,zmax=2.5
      (%
	(1.414213562*cosrad(sc)*cosrad(tc)
	  -2*sinrad(sc)*sinrad(tc))/(2*(abs(tc) + 1)) + sinrad(tc),%
	cosrad(tc) - (1.414213562*cosrad(sc)*sinrad(tc)
	  + 2*sinrad(sc)*cosrad(tc))/(2*(abs(tc) + 1)),% 
	tc - 2*cosrad(sc)/(2*(abs(tc) + 1))
	)%
% A space tube governed by a helix
    enddef;

def zsurface( expr xc, yc ) =
	( xc, yc, cosd(xc*57)*cosd(yc*57)+4*mexp(-(xc**2+yc**2)*6.4) )
enddef;

f:=(8,1.5,1.5);
Spread := 127;


beginfig(1); 
  numeric Ns, Nt, lows, higs, lowt, higt, lowx, highx, lowy, highy,
  facz, lowz, higz, base, topo; 
  path chair;
  % for torus
  f:=(4,1.5,1.5);
  Spread:=150;
  Ns = 16;
  Nt=  16;
  lows := 3.145*0.25;
  higs := 3.145*1.75;
  lowt = -3.145;
  higt = 3.145;
  facz=1;
  lowz = -5;
  higz = 5;
  lowx:=-5;
  lowy:=-5;
  higx:=10;
  higy:=7;
%    
  NF:=0; %Initialize number of faces;
%
  partrimesh( Ns,Nt,lowt,higt,lows,higs,
                    lowx,higx,lowy,higy,lowz,higz,facz,parsurfacetwo );
  lows := 3.145*0.5;
  higs := 2.25*3.145; % new parameters and new surface
  partrimesh( Ns,Nt,lowt,higt,lows,higs,
                    lowx,higx,lowy,higy,lowz,higz,facz,parsurface );
  base = -1/facz;
  topo = 1/facz;
  chair = rp((-1,-1,base))--rp((1,-1,base))--rp((1,1,base))
  --rp((-1,1,base))--rp((-1,-1,base))--rp((-1,-1,topo))
  --rp((-1,1,topo))--rp((-1,1,base))--cycle;
  draw_invisible( false,true,(blue+0.5green),0.6white);
  draw bbox currentpicture;
endfig;
  
beginfig(2); 
  numeric Ns, Nt, lows, higs, lowt, higt, lowx, highx, lowy, highy,
  facz, lowz, higz, base, topo; 
  path chair;

  f := (6,0.5,3); 
  Spread:=150;

  Ns = 19;
  Nt=  19;
  lows := -3.145;
  higs := 3.145;
  lowt = -3.145;
  higt = 3.145;
  facz = 2;
  lowz = -2;
  higz = 2;
  lowx:=-5;
  lowy:=-5;
  higx:=5;
  higy:=5;
  NF:=0; %Initialize number of faces;
%
  partrimesh( Ns,Nt,lowt,higt,lows,higs,
                    lowx,higx,lowy,higy,lowz,higz,facz,parsurface );

  nx := 27;	
  lowy := -7;
  higy := 7;
  lowx := -7;
  higx := 7;
  facz := 2;
  lowz := -1;
  higz := 5;
  partrimesh( nx,nx,lowx,higx,lowy,higy,
	            lowx,higx,lowy,higy,lowz,higz,facz,zsurface);
  base = -1/facz;
  topo = 1/facz;
  chair = rp((-1,-1,base))--rp((1,-1,base))--rp((1,1,base))
  --rp((-1,1,base))--rp((-1,-1,base))--rp((-1,-1,topo))
  --rp((-1,1,topo))--rp((-1,1,base))--cycle;
  fill chair withcolor 0.9 blue+0.6white;
  draw chair withcolor 0.1white ;
  draw_invisible( false,false,(red+0.32blue),0.6white);
endfig;

verbatimtex \end{document} etex
  
end;