summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/highmemory/hiddenlinegraph.mp
blob: efa5cea37279df0cac305d82078bb9dadf94a08d (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
% hiddenlinegraph.mp
% L. Nobre G.
% 2003
% The application of the big nice trick to draw 3D hidden line surfaces 

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

def zsurfaci( expr xc, yc ) = 
	begingroup
		numeric zout;
		zout = yc**4-xc*yc*(1-yc**2);
		( ( xc, yc, zout ) )
	endgroup 
enddef;

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

def zsurfaca( expr xc, yc ) =
	( xc, yc, 1.5-0.2*xc )
enddef;

%f := (6,1,0);
f := (5,1.5,3);
Spread := 147;
NF := 0;
LightSource := (1,-1,2);

beginfig(1); 
	numeric nx, ny, lowx, higx, lowy, higy, 
	        facz, lowz, higz, base, topo;
	path chair;
	nx = 22;
	ny = 22;
	lowy = -7;
	higy = 7;
	lowx = -7;
	higx = 7;
	facz = 2;
	lowz = -1;
	higz = 5;
%	lowy = -2.5;
%	higy = 1;
%	lowx = 1.5;
%	higx = 3;
%	facz = 3;
%	lowz = -1.5;
%	higz = 1.5;
	partrimesh( nx,ny,lowx,higx,lowy,higy,
	                  lowx,higx,lowy,higy,lowz,higz,facz,zsurface);
	partrimesh( nx,ny,lowx,higx,lowy,higy,
	                  lowx,higx,lowy,higy,lowz,higz,facz,zsurfaca);
	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 chair;
%	fill_faces( withcolor blue );
	draw_invisible( false, false, green, blue );
endfig;

verbatimtex \end{document} etex

end;