1 /***************************************************************************
2  * samples.cpp is part of Math Graphic Library
3  * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 #include "mgl2/mgl.h"
21 //-----------------------------------------------------------------------------
22 void mgls_prepare1d(mglData *y, mglData *y1=0, mglData *y2=0, mglData *x1=0, mglData *x2=0);
23 void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0);
24 void mgls_prepare3d(mglData *a, mglData *b=0);
25 void mgls_prepare2v(mglData *a, mglData *b);
26 void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez);
27 extern int big;
28 //-----------------------------------------------------------------------------
29 struct mglSample	/// Structure for list of samples
30 {
31 	const char *name;
32 	void (*func)(mglGraph*);
33 	const char *mgl;
34 	const char *info;
35 };
36 //-----------------------------------------------------------------------------
37 //		MGL functions for preparing data
38 //-----------------------------------------------------------------------------
39 const char *mmgl_dat_prepare = "\nfunc 'prepare1d'\n\
40 new y 50 3\nmodify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)'\n\
41 modify y 'sin(2*pi*x)' 1\nmodify y 'cos(2*pi*x)' 2\n\
42 new x1 50 'x'\nnew x2 50 '0.05-0.03*cos(pi*x)'\n\
43 new y1 50 '0.5-0.3*cos(pi*x)'\nnew y2 50 '-0.3*sin(pi*x)'\n\
44 return\n\nfunc 'prepare2d'\n\
45 new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'\n\
46 new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'\n\
47 return\n\nfunc 'prepare3d'\n\
48 new c 61 50 40 '-2*(x^2+y^2+z^4-z^2)+0.2'\n\
49 new d 61 50 40 '1-2*tanh((x+y)*(x+y))'\n\
50 return\n\nfunc 'prepare2v'\n\
51 new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'\n\
52 new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'\n\
53 return\n\nfunc 'prepare3v'\n\
54 define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5)\n\
55 define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5)\n\
56 new ex 10 10 10 '0.2*x/$1-0.2*x/$2'\n\
57 new ey 10 10 10 '0.2*y/$1-0.2*y/$2'\n\
58 new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2'\nreturn";
59 //-----------------------------------------------------------------------------
60 //		Sample functions (v.2.*)
61 //-----------------------------------------------------------------------------
62 const char *mmgl_refill="new x 10 '0.5+rnd':cumsum x 'x':norm x -1 1\ncopy y sin(pi*x)/1.5\n"
63 "subplot 2 2 0 '<_':title 'Refill sample'\nbox:axis:plot x y 'o ':fplot 'sin(pi*x)/1.5' 'B:'\n"
64 "new r 100:refill r x y:plot r 'r'\n\n"
65 "subplot 2 2 1 '<_':title 'Global spline'\nbox:axis:plot x y 'o ':fplot 'sin(pi*x)/1.5' 'B:'\n"
66 "new r 100:gspline r x y:plot r 'r'\n\nnew y 10 '0.5+rnd':cumsum y 'x':norm y -1 1\n"
67 "copy xx x:extend xx 10\ncopy yy y:extend yy 10:transpose yy\ncopy z sin(pi*xx*yy)/1.5\n"
68 "alpha on:light on\n"
69 "subplot 2 2 2:title '2d regular':rotate 40 60\nbox:axis:mesh xx yy z 'k'\n"
70 "new rr 100 100:refill rr x y z:surf rr\n\n"
71 "new xx 10 10 '(x+1)/2*cos(y*pi/2-1)':new yy 10 10 '(x+1)/2*sin(y*pi/2-1)'\ncopy z sin(pi*xx*yy)/1.5\n"
72 "subplot 2 2 3:title '2d non-regular':rotate 40 60\nbox:axis:plot xx yy z 'ko '\n"
73 "new rr 100 100:refill rr xx yy z:surf rr";
smgl_refill(mglGraph * gr)74 void smgl_refill(mglGraph *gr)
75 {
76 	mglData x(10), y(10), r(100);
77 	x.Modify("0.5+rnd");	x.CumSum("x");	x.Norm(-1,1);
78 	y.Modify("sin(pi*v)/1.5",x);
79 	if(big!=3)	{	gr->SubPlot(2,2,0,"<_");	gr->Title("Refill sample");	}
80 	gr->Axis();	gr->Box();	gr->Plot(x,y,"o ");
81 	gr->Refill(r,x,y);	// or you can use r.Refill(x,y,-1,1);
82 	gr->Plot(r,"r");	gr->FPlot("sin(pi*x)/1.5","B:");
83 	if(big==3)	return;
84 	gr->SubPlot(2,2,1,"<_");	gr->Title("Global spline");
85 	gr->Axis();	gr->Box();	gr->Plot(x,y,"o ");
86 	r.RefillGS(x,y,-1,1);	gr->Plot(r,"r");
87 	gr->FPlot("sin(pi*x)/1.5","B:");
88 
89 	gr->Alpha(true);	gr->Light(true);
90 	mglData z(10,10), xx(10,10), yy(10,10), rr(100,100);
91 	y.Modify("0.5+rnd");	y.CumSum("x");	y.Norm(-1,1);
92 	for(int i=0;i<10;i++)	for(int j=0;j<10;j++)
93 		z.a[i+10*j] = sin(M_PI*x.a[i]*y.a[j])/1.5;
94 	gr->SubPlot(2,2,2);	gr->Title("2d regular");	gr->Rotate(40,60);
95 	gr->Axis();	gr->Box();	gr->Mesh(x,y,z,"k");
96 	gr->Refill(rr,x,y,z);	gr->Surf(rr);
97 
98 	gr->Fill(xx,"(x+1)/2*cos(y*pi/2-1)");
99 	gr->Fill(yy,"(x+1)/2*sin(y*pi/2-1)");
100 	for(int i=0;i<10*10;i++)
101 		z.a[i] = sin(M_PI*xx.a[i]*yy.a[i])/1.5;
102 	gr->SubPlot(2,2,3);	gr->Title("2d non-regular");	gr->Rotate(40,60);
103 	gr->Axis();	gr->Box();	gr->Plot(xx,yy,z,"ko ");
104 	gr->Refill(rr,xx,yy,z);	gr->Surf(rr);
105 }
106 //-----------------------------------------------------------------------------
107 const char *mmgl_indirect="subplot 1 1 0 '':title 'SubData vs Evaluate'\n"
108 "new in 9 'x^3/1.1':plot in 'ko ':box\nnew arg 99 '4*x+4'\n"
109 "evaluate e in arg off:plot e 'b.'; legend 'Evaluate'\n"
110 "subdata s in arg:plot s 'r.';legend 'SubData'\nlegend 2";
smgl_indirect(mglGraph * gr)111 void smgl_indirect(mglGraph *gr)
112 {
113 	gr->SubPlot(1,1,0,"");	gr->Title("SubData vs Evaluate");
114 	mglData in(9), arg(99), e, s;
115 	gr->Fill(in,"x^3/1.1");	gr->Fill(arg,"4*x+4");
116 	gr->Plot(in,"ko ");		gr->Box();
117 	e = in.Evaluate(arg,false);	gr->Plot(e,"b.","legend 'Evaluate'");
118 	s = in.SubData(arg);	gr->Plot(s,"r.","legend 'SubData'");
119 	gr->Legend(2);
120 }
121 //-----------------------------------------------------------------------------
122 const char *mmgl_ode="subplot 2 2 0 '<_':title 'Cont':box\naxis:xlabel 'x':ylabel '\\dot{x}'\n"
123 "new f 100 100 'y^2+2*x^3-x^2-0.5':cont f\n\n"
124 "subplot 2 2 1 '<_':title 'Flow':box\naxis:xlabel 'x':ylabel '\\dot{x}'\n"
125 "new fx 100 100 'x-3*x^2'\nnew fy 100 100 'y'\nflow fy fx 'v';value 7\n\n"
126 "subplot 2 2 2 '<_':title 'ODE':box\naxis:xlabel 'x':ylabel '\\dot{x}'\n"
127 "for $x -1 1 0.1\n  ode r 'y;x-3*x^2' 'xy' [$x,0]\n  plot r(0) r(1)\n"
128 "  ode r '-y;-x+3*x^2' 'xy' [$x,0]\n  plot r(0) r(1)\nnext";
smgl_ode(mglGraph * gr)129 void smgl_ode(mglGraph *gr)
130 {
131 	gr->SubPlot(2,2,0,"<_");	gr->Title("Cont");	gr->Box();
132 	gr->Axis();	gr->Label('x',"x");	gr->Label('y',"\\dot{x}");
133 	mglData f(100,100);	gr->Fill(f,"y^2+2*x^3-x^2-0.5");
134 	gr->Cont(f);
135 	gr->SubPlot(2,2,1,"<_");	gr->Title("Flow");	gr->Box();
136 	gr->Axis();	gr->Label('x',"x");	gr->Label('y',"\\dot{x}");
137 	mglData fx(100,100), fy(100,100);	gr->Fill(fx,"x-3*x^2");	gr->Fill(fy,"y");
138 	gr->Flow(fy,fx,"v","value 7");
139 	gr->SubPlot(2,2,2,"<_");	gr->Title("ODE");	gr->Box();
140 	gr->Axis();	gr->Label('x',"x");	gr->Label('y',"\\dot{x}");
141 	for(double x=-1;x<1;x+=0.1)
142 	{
143 		mglData in(2), r;	in.a[0]=x;
144 		r = mglODE("y;x-3*x^2","xy",in);
145 		gr->Plot(r.SubData(0), r.SubData(1));
146 		r = mglODE("-y;-x+3*x^2","xy",in);
147 		gr->Plot(r.SubData(0), r.SubData(1));
148 	}
149 }
150 //-----------------------------------------------------------------------------
151 const char *mmgl_correl="new a 100 'exp(-10*x^2)'\n"
152 "new b 100 'exp(-10*(x+0.5)^2)'\n"
153 "yrange 0 1\nsubplot 1 2 0 '_':title 'Input fields'\n"
154 "plot a:plot b:box:axis\n"
155 "correl r a b 'x'\nnorm r 0 1:swap r 'x' # make it human readable\n"
156 "subplot 1 2 1 '_':title 'Correlation of a and b'\n"
157 "plot r 'r':axis:box\nline 0.5 0 0.5 1 'B|'";
smgl_correl(mglGraph * gr)158 void smgl_correl(mglGraph *gr)
159 {
160 	mglData a(100),b(100);
161 	gr->Fill(a,"exp(-10*x^2)");	gr->Fill(b,"exp(-10*(x+0.5)^2)");
162 	gr->SetRange('y',0,1);
163 	gr->SubPlot(1,2,0,"_");	gr->Title("Input fields");
164 	gr->Plot(a);	gr->Plot(b);	gr->Axis();	gr->Box();
165 	mglData r = a.Correl(b,"x");
166 	r.Norm(0,1);	r.Swap("x");	// make it human readable
167 	gr->SubPlot(1,2,1,"_");	gr->Title("Correlation of a and b");
168 	gr->Plot(r,"r");	gr->Axis();	gr->Box();
169 	gr->Line(mglPoint(0.5,0),mglPoint(0.5,1),"B|");
170 }
171 //-----------------------------------------------------------------------------
172 const char *mmgl_mask="new a 10 10 'x'\n"
173 "subplot 5 4 0 '':title '\"-\" mask':dens a '3-'\n"
174 "subplot 5 4 1 '':title '\"+\" mask':dens a '3+'\n"
175 "subplot 5 4 2 '':title '\"=\" mask':dens a '3='\n"
176 "subplot 5 4 3 '':title '\";\" mask':dens a '3;'\n"
177 "subplot 5 4 4 '':title '\";I\" mask':dens a '3;I'\n"
178 "subplot 5 4 5 '':title '\"o\" mask':dens a '3o'\n"
179 "subplot 5 4 6 '':title '\"O\" mask':dens a '3O'\n"
180 "subplot 5 4 7 '':title '\"s\" mask':dens a '3s'\n"
181 "subplot 5 4 8 '':title '\"S\" mask':dens a '3S'\n"
182 "subplot 5 4 9 '':title '\";/\" mask':dens a '3;/'\n"
183 "subplot 5 4 10 '':title '\"~\" mask':dens a '3~'\n"
184 "subplot 5 4 11 '':title '\"<\" mask':dens a '3<'\n"
185 "subplot 5 4 12 '':title '\">\" mask':dens a '3>'\n"
186 "subplot 5 4 13 '':title '\"j\" mask':dens a '3j'\n"
187 "subplot 5 4 14 '':title '\"-;\\\" mask':dens a '3\\;'\n"
188 "subplot 5 4 15 '':title '\"d\" mask':dens a '3d'\n"
189 "subplot 5 4 16 '':title '\"D\" mask':dens a '3D'\n"
190 "subplot 5 4 17 '':title '\"*\" mask':dens a '3*'\n"
191 "subplot 5 4 18 '':title '\"\\^\" mask':dens a '3^'\n"
192 "subplot 5 4 19 '':title 'manual mask'\n"
193 "mask '+' '24242424FF0101FF':dens a '3+'";
smgl_mask(mglGraph * gr)194 void smgl_mask(mglGraph *gr)
195 {
196 	mglData a(10,10);	a.Fill(-1,1);
197 	gr->SubPlot(5,4,0,"");	gr->Title("'-' mask");	gr->Dens(a,"3-");
198 	gr->SubPlot(5,4,1,"");	gr->Title("'+' mask");	gr->Dens(a,"3+");
199 	gr->SubPlot(5,4,2,"");	gr->Title("'=' mask");	gr->Dens(a,"3=");
200 	gr->SubPlot(5,4,3,"");	gr->Title("';' mask");	gr->Dens(a,"3;");
201 	gr->SubPlot(5,4,4,"");	gr->Title("';I' mask");	gr->Dens(a,"3;I");
202 	gr->SubPlot(5,4,5,"");	gr->Title("'o' mask");	gr->Dens(a,"3o");
203 	gr->SubPlot(5,4,6,"");	gr->Title("'O' mask");	gr->Dens(a,"3O");
204 	gr->SubPlot(5,4,7,"");	gr->Title("'s' mask");	gr->Dens(a,"3s");
205 	gr->SubPlot(5,4,8,"");	gr->Title("'S' mask");	gr->Dens(a,"3S");
206 	gr->SubPlot(5,4,9,"");	gr->Title("';/' mask");	gr->Dens(a,"3;/");
207 	gr->SubPlot(5,4,10,"");	gr->Title("'~' mask");	gr->Dens(a,"3~");
208 	gr->SubPlot(5,4,11,"");	gr->Title("'<' mask");	gr->Dens(a,"3<");
209 	gr->SubPlot(5,4,12,"");	gr->Title("'>' mask");	gr->Dens(a,"3>");
210 	gr->SubPlot(5,4,13,"");	gr->Title("'j' mask");	gr->Dens(a,"3j");
211 	gr->SubPlot(5,4,14,"");	gr->Title("';\\\\' mask");	gr->Dens(a,"3;\\");
212 	gr->SubPlot(5,4,15,"");	gr->Title("'d' mask");	gr->Dens(a,"3d");
213 	gr->SubPlot(5,4,16,"");	gr->Title("'D' mask");	gr->Dens(a,"3D");
214 	gr->SubPlot(5,4,17,"");	gr->Title("'*' mask");	gr->Dens(a,"3*");
215 	gr->SubPlot(5,4,18,"");	gr->Title("'\\^' mask");	gr->Dens(a,"3^");
216 	gr->SubPlot(5,4,19,"");	gr->Title("manual mask");
217 	gr->SetMask('+', "24242424FF0101FF");	gr->Dens(a,"3+");
218 }
219 //-----------------------------------------------------------------------------
220 const char *mmgl_export="new a 100 100 'x^2*y':new b 100 100\n"
221 "export a 'test_data.png' 'BbcyrR' -1 1\n"
222 "import b 'test_data.png' 'BbcyrR' -1 1\n"
223 "subplot 2 1 0 '':title 'initial':box:dens a\n"
224 "subplot 2 1 1 '':title 'imported':box:dens b";
smgl_export(mglGraph * gr)225 void smgl_export(mglGraph *gr)	// basic data operations
226 {
227 	mglData a(100,100), b; gr->Fill(a,"x^2*y");
228 	a.Export("test_data.png","BbcyrR");
229 	b.Import("test_data.png","BbcyrR",-1,1);
230 	gr->SubPlot(2,1,0,"");	gr->Title("initial");	gr->Box();	gr->Dens(a);
231 	gr->SubPlot(2,1,1,"");	gr->Title("imported");	gr->Box();	gr->Dens(b);
232 }
233 //-----------------------------------------------------------------------------
234 const char *mmgl_data1="new a 40 50 60 'exp(-x^2-4*y^2-16*z^2)'\n"
235 "light on:alpha on\n"
236 "copy b a:diff b 'x':subplot 5 3 0:call 'splot'\n"
237 "copy b a:diff2 b 'x':subplot 5 3 1:call 'splot'\n"
238 "copy b a:cumsum b 'x':subplot 5 3 2:call 'splot'\n"
239 "copy b a:integrate b 'x':subplot 5 3 3:call 'splot'\n"
240 "mirror b 'x':subplot 5 3 4:call 'splot'\n"
241 "copy b a:diff b 'y':subplot 5 3 5:call 'splot'\n"
242 "copy b a:diff2 b 'y':subplot 5 3 6:call 'splot'\n"
243 "copy b a:cumsum b 'y':subplot 5 3 7:call 'splot'\n"
244 "copy b a:integrate b 'y':subplot 5 3 8:call 'splot'\n"
245 "mirror b 'y':subplot 5 3 9:call 'splot'\n"
246 "copy b a:diff b 'z':subplot 5 3 10:call 'splot'\n"
247 "copy b a:diff2 b 'z':subplot 5 3 11:call 'splot'\n"
248 "copy b a:cumsum b 'z':subplot 5 3 12:call 'splot'\n"
249 "copy b a:integrate b 'z':subplot 5 3 13:call 'splot'\n"
250 "mirror b 'z':subplot 5 3 14:call 'splot'\n"
251 "stop\nfunc splot 0\n"
252 "title 'max=',b.max:norm b -1 1 on:rotate 70 60:box:surf3 b\n"
253 "return";
splot1(mglGraph * gr,mglData & b)254 inline void splot1(mglGraph *gr, mglData &b)
255 {b.Norm(-1,1,true);gr->Rotate(70,60);gr->Box();gr->Surf3(b);}
smgl_data1(mglGraph * gr)256 void smgl_data1(mglGraph *gr)	// basic data operations
257 {
258 	mglData a(40,50,60),b;	gr->Fill(a,"exp(-x^2-4*y^2-16*z^2)");
259 	gr->Light(true);		gr->Alpha(true);
260 	b.Set(a);	b.Diff("x");	gr->SubPlot(5,3,0);	splot1(gr,b);
261 	b.Set(a);	b.Diff2("x");	gr->SubPlot(5,3,1);	splot1(gr,b);
262 	b.Set(a);	b.CumSum("x");	gr->SubPlot(5,3,2);	splot1(gr,b);
263 	b.Set(a);	b.Integral("x");gr->SubPlot(5,3,3);	splot1(gr,b);
264 	b.Mirror("x");	gr->SubPlot(5,3,4);	splot1(gr,b);
265 	b.Set(a);	b.Diff("y");	gr->SubPlot(5,3,5);	splot1(gr,b);
266 	b.Set(a);	b.Diff2("y");	gr->SubPlot(5,3,6);	splot1(gr,b);
267 	b.Set(a);	b.CumSum("y");	gr->SubPlot(5,3,7);	splot1(gr,b);
268 	b.Set(a);	b.Integral("y");gr->SubPlot(5,3,8);	splot1(gr,b);
269 	b.Mirror("y");	gr->SubPlot(5,3,9);	splot1(gr,b);
270 	b.Set(a);	b.Diff("z");	gr->SubPlot(5,3,10);splot1(gr,b);
271 	b.Set(a);	b.Diff2("z");	gr->SubPlot(5,3,11);splot1(gr,b);
272 	b.Set(a);	b.CumSum("z");	gr->SubPlot(5,3,12);splot1(gr,b);
273 	b.Set(a);	b.Integral("z");gr->SubPlot(5,3,13);splot1(gr,b);
274 	b.Mirror("z");	gr->SubPlot(5,3,14);splot1(gr,b);
275 }
276 //-----------------------------------------------------------------------------
277 const char *mmgl_data2="new a 40 50 60 'exp(-x^2-4*y^2-16*z^2)'\n"
278 "light on:alpha on\n"
279 "copy b a:sinfft b 'x':subplot 5 3 0:call 'splot'\n"
280 "copy b a:cosfft b 'x':subplot 5 3 1:call 'splot'\n"
281 "copy b a:hankel b 'x':subplot 5 3 2:call 'splot'\n"
282 "copy b a:swap b 'x':subplot 5 3 3:call 'splot'\n"
283 "copy b a:smooth b 'x':subplot 5 3 4:call 'splot'\n"
284 "copy b a:sinfft b 'y':subplot 5 3 5:call 'splot'\n"
285 "copy b a:cosfft b 'y':subplot 5 3 6:call 'splot'\n"
286 "copy b a:hankel b 'y':subplot 5 3 7:call 'splot'\n"
287 "copy b a:swap b 'y':subplot 5 3 8:call 'splot'\n"
288 "copy b a:smooth b 'y':subplot 5 3 9:call 'splot'\n"
289 "copy b a:sinfft b 'z':subplot 5 3 10:call 'splot'\n"
290 "copy b a:cosfft b 'z':subplot 5 3 11:call 'splot'\n"
291 "copy b a:hankel b 'z':subplot 5 3 12:call 'splot'\n"
292 "copy b a:swap b 'z':subplot 5 3 13:call 'splot'\n"
293 "copy b a:smooth b 'z':subplot 5 3 14:call 'splot'\n"
294 "stop\nfunc splot 0\n"
295 "title 'max=',b.max:norm b -1 1 on:rotate 70 60:box\n"
296 "surf3 b 0.5:surf3 b -0.5\nreturn";
splot2(mglGraph * gr,mglData & b)297 inline void splot2(mglGraph *gr, mglData &b)
298 {b.Norm(-1,1,true);gr->Rotate(70,60);gr->Box();gr->Surf3(0.5,b);gr->Surf3(-0.5,b);}
smgl_data2(mglGraph * gr)299 void smgl_data2(mglGraph *gr)	// data transforms
300 {
301 	mglData a(40,50,60),b;	gr->Fill(a,"exp(-x^2-4*y^2-16*z^2)");
302 	gr->Light(true);		gr->Alpha(true);
303 	b.Set(a);	b.SinFFT("x");	gr->SubPlot(5,3,0);	splot2(gr,b);
304 	b.Set(a);	b.CosFFT("x");	gr->SubPlot(5,3,1);	splot2(gr,b);
305 	b.Set(a);	b.Hankel("x");	gr->SubPlot(5,3,2);	splot2(gr,b);
306 	b.Set(a);	b.Swap("x");	gr->SubPlot(5,3,3);	splot2(gr,b);
307 	b.Set(a);	b.Smooth("x");	gr->SubPlot(5,3,4);	splot2(gr,b);
308 	b.Set(a);	b.SinFFT("y");	gr->SubPlot(5,3,5);	splot2(gr,b);
309 	b.Set(a);	b.CosFFT("y");	gr->SubPlot(5,3,6);	splot2(gr,b);
310 	b.Set(a);	b.Hankel("y");	gr->SubPlot(5,3,7);	splot2(gr,b);
311 	b.Set(a);	b.Swap("y");	gr->SubPlot(5,3,8);	splot2(gr,b);
312 	b.Set(a);	b.Smooth("y");	gr->SubPlot(5,3,9);	splot2(gr,b);
313 	b.Set(a);	b.SinFFT("z");	gr->SubPlot(5,3,10);splot2(gr,b);
314 	b.Set(a);	b.CosFFT("z");	gr->SubPlot(5,3,11);splot2(gr,b);
315 	b.Set(a);	b.Hankel("z");	gr->SubPlot(5,3,12);splot2(gr,b);
316 	b.Set(a);	b.Swap("z");	gr->SubPlot(5,3,13);splot2(gr,b);
317 	b.Set(a);	b.Smooth("z");	gr->SubPlot(5,3,14);splot2(gr,b);
318 }
319 //-----------------------------------------------------------------------------
320 const char *mmgl_param1="new x 100 'sin(pi*x)'\nnew y 100 'cos(pi*x)'\n"
321 "new z 100 'sin(2*pi*x)'\nnew c 100 'cos(2*pi*x)'\n\n"
322 "subplot 4 3 0:rotate 40 60:box:plot x y z\n"
323 "subplot 4 3 1:rotate 40 60:box:area x y z\n"
324 "subplot 4 3 2:rotate 40 60:box:tens x y z c\n"
325 "subplot 4 3 3:rotate 40 60:box:bars x y z\n"
326 "subplot 4 3 4:rotate 40 60:box:stem x y z\n"
327 "subplot 4 3 5:rotate 40 60:box:textmark x y z c*2 '\\alpha'\n"
328 "subplot 4 3 6:rotate 40 60:box:tube x y z c/10\n"
329 "subplot 4 3 7:rotate 40 60:box:mark x y z c 's'\n"
330 "subplot 4 3 8:box:error x y z/10 c/10\n"
331 "subplot 4 3 9:rotate 40 60:box:step x y z\n"
332 "subplot 4 3 10:rotate 40 60:box:torus x z 'z';light on\n"
333 "subplot 4 3 11:rotate 40 60:box:label x y z '%z'";
smgl_param1(mglGraph * gr)334 void smgl_param1(mglGraph *gr)	// 1d parametric plots
335 {
336 	mglData x(100), y(100), z(100), c(100);
337 	gr->Fill(x,"sin(pi*x)");	gr->Fill(y,"cos(pi*x)");
338 	gr->Fill(z,"sin(2*pi*x)");	gr->Fill(c,"cos(2*pi*x)");
339 
340 	gr->SubPlot(4,3,0);	gr->Rotate(40,60);	gr->Box();	gr->Plot(x,y,z);
341 	gr->SubPlot(4,3,1);	gr->Rotate(40,60);	gr->Box();	gr->Area(x,y,z);
342 	gr->SubPlot(4,3,2);	gr->Rotate(40,60);	gr->Box();	gr->Tens(x,y,z,c);
343 	gr->SubPlot(4,3,3);	gr->Rotate(40,60);	gr->Box();	gr->Bars(x,y,z);
344 	gr->SubPlot(4,3,4);	gr->Rotate(40,60);	gr->Box();	gr->Stem(x,y,z);
345 	gr->SubPlot(4,3,5);	gr->Rotate(40,60);	gr->Box();	gr->TextMark(x,y,z,c*2,"\\alpha");
346 	gr->SubPlot(4,3,6);	gr->Rotate(40,60);	gr->Box();	gr->Tube(x,y,z,c/10,"","light on");
347 	gr->SubPlot(4,3,7);	gr->Rotate(40,60);	gr->Box();	gr->Mark(x,y,z,c,"s");
348 	gr->SubPlot(4,3,8);	gr->Rotate(40,60);	gr->Box();	gr->Error(x,y,z/10,c/10);
349 	gr->SubPlot(4,3,9);	gr->Rotate(40,60);	gr->Box();	gr->Step(x,y,z);
350 	gr->SubPlot(4,3,10);gr->Rotate(40,60);	gr->Box();	gr->Torus(x,z,"z","light on");
351 	gr->SubPlot(4,3,11);gr->Rotate(40,60);	gr->Box();	gr->Label(x,y,z,"%z");
352 }
353 //-----------------------------------------------------------------------------
354 const char *mmgl_param2="new x 100 100 'sin(pi*(x+y)/2)*cos(pi*y/2)'\n"
355 "new y 100 100 'cos(pi*(x+y)/2)*cos(pi*y/2)'\n"
356 "new z 100 100 'sin(pi*y/2)'\nnew c 100 100 'cos(pi*x)'\n\n"
357 "subplot 4 4 0:rotate 40 60:box:surf x y z\n"
358 "subplot 4 4 1:rotate 40 60:box:surfc x y z c\n"
359 "subplot 4 4 2:rotate 40 60:box:surfa x y z c;alpha 1\n"
360 "subplot 4 4 3:rotate 40 60:box:mesh x y z;meshnum 10\n"
361 "subplot 4 4 4:rotate 40 60:box:tile x y z;meshnum 10\n"
362 "subplot 4 4 5:rotate 40 60:box:tiles x y z c;meshnum 10\n"
363 "subplot 4 4 6:rotate 40 60:box:axial x y z;alpha 0.5;light on\n"
364 "subplot 4 4 7:rotate 40 60:box:cont x y z\n"
365 "subplot 4 4 8:rotate 40 60:box:contf x y z;light on:contv x y z;light on\n"
366 "subplot 4 4 9:rotate 40 60:box:belt x y z 'x';meshnum 10;light on\n"
367 "subplot 4 4 10:rotate 40 60:box:dens x y z;alpha 0.5\n"
368 "subplot 4 4 11:rotate 40 60:box\n"
369 "fall x y z 'g';meshnum 10:fall x y z 'rx';meshnum 10\n"
370 "subplot 4 4 12:rotate 40 60:box:belt x y z '';meshnum 10;light on\n"
371 "subplot 4 4 13:rotate 40 60:box:boxs x y z '';meshnum 10;light on\n"
372 "subplot 4 4 14:rotate 40 60:box:boxs x y z '#';meshnum 10;light on\n"
373 "subplot 4 4 15:rotate 40 60:box:boxs x y z '@';meshnum 10;light on";
smgl_param2(mglGraph * gr)374 void smgl_param2(mglGraph *gr)	// 2d parametric plots
375 {
376 	mglData x(100,100), y(100,100), z(100,100), c(100,100);
377 	gr->Fill(x,"sin(pi*(x+y)/2)*cos(pi*y/2)");	gr->Fill(y,"cos(pi*(x+y)/2)*cos(pi*y/2)");
378 	gr->Fill(z,"sin(pi*y/2)");	gr->Fill(c,"cos(pi*x)");
379 
380 	gr->SubPlot(4,4,0);	gr->Rotate(40,60);	gr->Box();	gr->Surf(x,y,z);
381 	gr->SubPlot(4,4,1);	gr->Rotate(40,60);	gr->Box();	gr->SurfC(x,y,z,c);
382 	gr->SubPlot(4,4,2);	gr->Rotate(40,60);	gr->Box();	gr->SurfA(x,y,z,c,"","alpha 1");
383 	gr->SubPlot(4,4,3);	gr->Rotate(40,60);	gr->Box();	gr->Mesh(x,y,z,"","meshnum 10");
384 	gr->SubPlot(4,4,4);	gr->Rotate(40,60);	gr->Box();	gr->Tile(x,y,z,"","meshnum 10");
385 	gr->SubPlot(4,4,5);	gr->Rotate(40,60);	gr->Box();	gr->TileS(x,y,z,c,"","meshnum 10");
386 	gr->SubPlot(4,4,6);	gr->Rotate(40,60);	gr->Box();	gr->Axial(x,y,z,"","alpha 0.5;light on");
387 	gr->SubPlot(4,4,7);	gr->Rotate(40,60);	gr->Box();	gr->Cont(x,y,z);
388 	gr->SubPlot(4,4,8);	gr->Rotate(40,60);	gr->Box();	gr->ContF(x,y,z,"","light on");	gr->ContV(x,y,z,"","light on");
389 	gr->SubPlot(4,4,9);	gr->Rotate(40,60);	gr->Box();	gr->Belt(x,y,z,"x","meshnum 10;light on");
390 	gr->SubPlot(4,4,10);gr->Rotate(40,60);	gr->Box();	gr->Dens(x,y,z,"","alpha 0.5");
391 	gr->SubPlot(4,4,11);gr->Rotate(40,60);	gr->Box();
392 	gr->Fall(x,y,z,"g","meshnum 10");	gr->Fall(x,y,z,"rx","meshnum 10");
393 	gr->SubPlot(4,4,12);	gr->Rotate(40,60);	gr->Box();	gr->Belt(x,y,z,"","meshnum 10;light on");
394 	gr->SubPlot(4,4,13);	gr->Rotate(40,60);	gr->Box();	gr->Boxs(x,y,z,"","meshnum 10;light on");
395 	gr->SubPlot(4,4,14);	gr->Rotate(40,60);	gr->Box();	gr->Boxs(x,y,z,"#","meshnum 10");
396 	gr->SubPlot(4,4,15);	gr->Rotate(40,60);	gr->Box();	gr->Boxs(x,y,z,"@","meshnum 10;light on");
397 }
398 //-----------------------------------------------------------------------------
399 const char *mmgl_param3="new x 50 50 50 '(x+2)/3*sin(pi*y/2)'\n"
400 "new y 50 50 50 '(x+2)/3*cos(pi*y/2)'\nnew z 50 50 50 'z'\n"
401 "new c 50 50 50 '-2*(x^2+y^2+z^4-z^2)+0.2'\n"
402 "new d 50 50 50 '1-2*tanh(2*(x+y)^2)'\n\n"
403 "alpha on:light on\n"
404 "subplot 4 3 0:rotate 40 60:box:surf3 x y z c\n"
405 "subplot 4 3 1:rotate 40 60:box:surf3c x y z c d\n"
406 "subplot 4 3 2:rotate 40 60:box:surf3a x y z c d\n"
407 "subplot 4 3 3:rotate 40 60:box:cloud x y z c\n"
408 "subplot 4 3 4:rotate 40 60:box:cont3 x y z c:cont3 x y z c 'x':cont3 x y z c 'z'\n"
409 "subplot 4 3 5:rotate 40 60:box:contf3 x y z c:contf3 x y z c 'x':contf3 x y z c 'z'\n"
410 "subplot 4 3 6:rotate 40 60:box:dens3 x y z c:dens3 x y z c 'x':dens3 x y z c 'z'\n"
411 "subplot 4 3 7:rotate 40 60:box:dots x y z c;meshnum 15\n"
412 "subplot 4 3 8:rotate 40 60:box:densx c '' 0:densy c '' 0:densz c '' 0\n"
413 "subplot 4 3 9:rotate 40 60:box:contx c '' 0:conty c '' 0:contz c '' 0\n"
414 "subplot 4 3 10:rotate 40 60:box:contfx c '' 0:contfy c '' 0:contfz c '' 0";
smgl_param3(mglGraph * gr)415 void smgl_param3(mglGraph *gr)	// 3d parametric plots
416 {
417 	mglData x(50,50,50), y(50,50,50), z(50,50,50), c(50,50,50), d(50,50,50);
418 	gr->Fill(x,"(x+2)/3*sin(pi*y/2)");	gr->Fill(y,"(x+2)/3*cos(pi*y/2)");	gr->Fill(z,"z");
419 	gr->Fill(c,"-2*(x^2+y^2+z^4-z^2)+0.2");	gr->Fill(d,"1-2*tanh(2*(x+y)^2)");
420 
421 	gr->Light(true);	gr->Alpha(true);
422 	gr->SubPlot(4,3,0);	gr->Rotate(40,60);	gr->Box();	gr->Surf3(x,y,z,c);
423 	gr->SubPlot(4,3,1);	gr->Rotate(40,60);	gr->Box();	gr->Surf3C(x,y,z,c,d);
424 	gr->SubPlot(4,3,2);	gr->Rotate(40,60);	gr->Box();	gr->Surf3A(x,y,z,c,d);
425 	gr->SubPlot(4,3,3);	gr->Rotate(40,60);	gr->Box();	gr->Cloud(x,y,z,c);
426 	gr->SubPlot(4,3,4);	gr->Rotate(40,60);	gr->Box();	gr->Cont3(x,y,z,c);	gr->Cont3(x,y,z,c,"x");	gr->Cont3(x,y,z,c,"z");
427 	gr->SubPlot(4,3,5);	gr->Rotate(40,60);	gr->Box();	gr->ContF3(x,y,z,c);gr->ContF3(x,y,z,c,"x");gr->ContF3(x,y,z,c,"z");
428 	gr->SubPlot(4,3,6);	gr->Rotate(40,60);	gr->Box();	gr->Dens3(x,y,z,c);	gr->Dens3(x,y,z,c,"x");	gr->Dens3(x,y,z,c,"z");
429 	gr->SubPlot(4,3,7);	gr->Rotate(40,60);	gr->Box();	gr->Dots(x,y,z,c,"","meshnum 15");
430 	gr->SubPlot(4,3,8);	gr->Rotate(40,60);	gr->Box();	gr->DensX(c,"",0);	gr->DensY(c,"",0);	gr->DensZ(c,"",0);
431 	gr->SubPlot(4,3,9);	gr->Rotate(40,60);	gr->Box();	gr->ContX(c,"",0);	gr->ContY(c,"",0);	gr->ContZ(c,"",0);
432 	gr->SubPlot(4,3,10);gr->Rotate(40,60);	gr->Box();	gr->ContFX(c,"",0);	gr->ContFY(c,"",0);	gr->ContFZ(c,"",0);
433 }
434 //-----------------------------------------------------------------------------
435 const char *mmgl_paramv="new x 20 20 20 '(x+2)/3*sin(pi*y/2)'\n"
436 "new y 20 20 20 '(x+2)/3*cos(pi*y/2)'\nnew z 20 20 20 'z+x'\n"
437 "new ex 20 20 20 'x'\nnew ey 20 20 20 'x^2+y'\nnew ez 20 20 20 'y^2+z'\n\n"
438 "new x1 50 50 '(x+2)/3*sin(pi*y/2)'\n"
439 "new y1 50 50 '(x+2)/3*cos(pi*y/2)'\n"
440 "new e1 50 50 'x'\nnew e2 50 50 'x^2+y'\n\n"
441 "subplot 3 3 0:rotate 40 60:box:vect x1 y1 e1 e2\n"
442 "subplot 3 3 1:rotate 40 60:box:flow x1 y1 e1 e2\n"
443 "subplot 3 3 2:rotate 40 60:box:pipe x1 y1 e1 e2\n"
444 "subplot 3 3 3:rotate 40 60:box:dew x1 y1 e1 e2\n"
445 "subplot 3 3 4:rotate 40 60:box:vect x y z ex ey ez\n"
446 "subplot 3 3 5:rotate 40 60:box\n"
447 "vect3 x y z ex ey ez:vect3 x y z ex ey ez 'x':vect3 x y z ex ey ez 'z'\n"
448 "grid3 x y z z '{r9}':grid3 x y z z '{g9}x':grid3 x y z z '{b9}z'\n"
449 "subplot 3 3 6:rotate 40 60:box:flow x y z ex ey ez\n"
450 "subplot 3 3 7:rotate 40 60:box:pipe x y z ex ey ez";
smgl_paramv(mglGraph * gr)451 void smgl_paramv(mglGraph *gr)	// parametric plots for vector field
452 {
453 	mglData x(20,20,20), y(20,20,20), z(20,20,20), ex(20,20,20), ey(20,20,20), ez(20,20,20);
454 	gr->Fill(x,"(x+2)/3*sin(pi*y/2)");	gr->Fill(y,"(x+2)/3*cos(pi*y/2)");	gr->Fill(z,"x+z");
455 	gr->Fill(ex,"x");	gr->Fill(ey,"x^2+y");	gr->Fill(ez,"y^2+z");
456 	mglData x1(20,20), y1(20,20), e1(20,20), e2(20,20);
457 	gr->Fill(x1,"(x+2)/3*sin(pi*y/2)");	gr->Fill(y1,"(x+2)/3*cos(pi*y/2)");
458 	gr->Fill(e1,"x");	gr->Fill(e2,"x^2+y");
459 
460 	gr->SubPlot(3,3,0);	gr->Rotate(40,60);	gr->Box();	gr->Vect(x1,y1,e1,e2);
461 	gr->SubPlot(3,3,1);	gr->Rotate(40,60);	gr->Box();	gr->Flow(x1,y1,e1,e2);
462 	gr->SubPlot(3,3,2);	gr->Rotate(40,60);	gr->Box();	gr->Pipe(x1,y1,e1,e2);
463 	gr->SubPlot(3,3,3);	gr->Rotate(40,60);	gr->Box();	gr->Dew(x1,y1,e1,e2);
464 	gr->SubPlot(3,3,4);	gr->Rotate(40,60);	gr->Box();	gr->Vect(x,y,z,ex,ey,ez);
465 	gr->SubPlot(3,3,5);	gr->Rotate(40,60);	gr->Box();
466 	gr->Vect3(x,y,z,ex,ey,ez);	gr->Vect3(x,y,z,ex,ey,ez,"x");	gr->Vect3(x,y,z,ex,ey,ez,"z");
467 	gr->Grid3(x,y,z,z,"{r9}");	gr->Grid3(x,y,z,z,"{g9}x");		gr->Grid3(x,y,z,z,"{b9}z");
468 	gr->SubPlot(3,3,6);	gr->Rotate(40,60);	gr->Box();	gr->Flow(x,y,z,ex,ey,ez);
469 	gr->SubPlot(3,3,7);	gr->Rotate(40,60);	gr->Box();	gr->Pipe(x,y,z,ex,ey,ez);
470 }
471 //-----------------------------------------------------------------------------
472 const char *mmgl_solve="zrange 0 1\nnew x 20 30 '(x+2)/3*cos(pi*y)'\n"
473 "new y 20 30 '(x+2)/3*sin(pi*y)'\nnew z 20 30 'exp(-6*x^2-2*sin(pi*y)^2)'\n\n"
474 "subplot 2 1 0:title 'Cartesian space':rotate 30 -40\naxis 'xyzU':box\nxlabel 'x':ylabel 'y'\n"
475 "origin 1 1:grid 'xy'\nmesh x y z\n\n"
476 "# section along 'x' direction\nsolve u x 0.5 'x'\nvar v u.nx 0 1\n"
477 "evaluate yy y u v\nevaluate xx x u v\nevaluate zz z u v\nplot xx yy zz 'k2o'\n\n"
478 "# 1st section along 'y' direction\nsolve u1 x -0.5 'y'\nvar v1 u1.nx 0 1\n"
479 "evaluate yy y v1 u1\nevaluate xx x v1 u1\nevaluate zz z v1 u1\nplot xx yy zz 'b2^'\n\n"
480 "# 2nd section along 'y' direction\nsolve u2 x -0.5 'y' u1\n"
481 "evaluate yy y v1 u2\nevaluate xx x v1 u2\nevaluate zz z v1 u2\nplot xx yy zz 'r2v'\n\n"
482 "subplot 2 1 1:title 'Accompanied space'\nranges 0 1 0 1:origin 0 0\n"
483 "axis:box:xlabel 'i':ylabel 'j':grid2 z 'h'\n\n"
484 "plot u v 'k2o':line 0.4 0.5 0.8 0.5 'kA'\n"
485 "plot v1 u1 'b2^':line 0.5 0.15 0.5 0.3 'bA'\n"
486 "plot v1 u2 'r2v':line 0.5 0.7 0.5 0.85 'rA'";
smgl_solve(mglGraph * gr)487 void smgl_solve(mglGraph *gr)	// solve and evaluate
488 {
489 	gr->SetRange('z',0,1);
490 	mglData x(20,30), y(20,30), z(20,30), xx,yy,zz;
491 	gr->Fill(x,"(x+2)/3*cos(pi*y)");
492 	gr->Fill(y,"(x+2)/3*sin(pi*y)");
493 	gr->Fill(z,"exp(-6*x^2-2*sin(pi*y)^2)");
494 
495 	gr->SubPlot(2,1,0);	gr->Title("Cartesian space");	gr->Rotate(30,-40);
496 	gr->Axis("xyzU");	gr->Box();	gr->Label('x',"x");	gr->Label('y',"y");
497 	gr->SetOrigin(1,1);	gr->Grid("xy");
498 	gr->Mesh(x,y,z);
499 
500 	// section along 'x' direction
501 	mglData u = x.Solve(0.5,'x');
502 	mglData v(u.nx);	v.Fill(0,1);
503 	xx = x.Evaluate(u,v);	yy = y.Evaluate(u,v);	zz = z.Evaluate(u,v);
504 	gr->Plot(xx,yy,zz,"k2o");
505 
506 	// 1st section along 'y' direction
507 	mglData u1 = x.Solve(-0.5,'y');
508 	mglData v1(u1.nx);	v1.Fill(0,1);
509 	xx = x.Evaluate(v1,u1);	yy = y.Evaluate(v1,u1);	zz = z.Evaluate(v1,u1);
510 	gr->Plot(xx,yy,zz,"b2^");
511 
512 	// 2nd section along 'y' direction
513 	mglData u2 = x.Solve(-0.5,'y',u1);
514 	xx = x.Evaluate(v1,u2);	yy = y.Evaluate(v1,u2);	zz = z.Evaluate(v1,u2);
515 	gr->Plot(xx,yy,zz,"r2v");
516 
517 	gr->SubPlot(2,1,1);	gr->Title("Accompanied space");
518 	gr->SetRanges(0,1,0,1);	gr->SetOrigin(0,0);
519 	gr->Axis();	gr->Box();	gr->Label('x',"i");	gr->Label('y',"j");
520 	gr->Grid(z,"h");
521 
522 	gr->Plot(u,v,"k2o");	gr->Line(mglPoint(0.4,0.5),mglPoint(0.8,0.5),"kA");
523 	gr->Plot(v1,u1,"b2^");	gr->Line(mglPoint(0.5,0.15),mglPoint(0.5,0.3),"bA");
524 	gr->Plot(v1,u2,"r2v");	gr->Line(mglPoint(0.5,0.7),mglPoint(0.5,0.85),"rA");
525 }
526 //-----------------------------------------------------------------------------
527 const char *mmgl_triangulation="new x 100 '2*rnd-1':new y 100 '2*rnd-1':copy z x^2-y^2\n"
528 "new g 30 30:triangulate d x y\n"
529 "title 'Triangulation'\nrotate 50 60:box:light on\n"
530 "triplot d x y z:triplot d x y z '#k'\ndatagrid g x y z:mesh g 'm'";
smgl_triangulation(mglGraph * gr)531 void smgl_triangulation(mglGraph *gr)	// surface triangulation
532 {
533 	mglData x(100), y(100), z(100);
534 	gr->Fill(x,"2*rnd-1");	gr->Fill(y,"2*rnd-1");	gr->Fill(z,"v^2-w^2",x,y);
535 	mglData d = mglTriangulation(x,y), g(30,30);
536 
537 	if(big!=3)	gr->Title("Triangulation");
538 	gr->Rotate(40,60);	gr->Box();	gr->Light(true);
539 	gr->TriPlot(d,x,y,z);	gr->TriPlot(d,x,y,z,"#k");
540 
541 	gr->DataGrid(g,x,y,z);	gr->Mesh(g,"m");
542 }
543 //-----------------------------------------------------------------------------
544 const char *mmgl_alpha="call 'prepare2d'\nsubplot 2 2 0:title 'default':rotate 50 60:box\nsurf a\n"
545 "subplot 2 2 1:title 'light on':rotate 50 60:box\nlight on:surf a\n"
546 "subplot 2 2 3:title 'light on; alpha on':rotate 50 60:box\nalpha on:surf a\n"
547 "subplot 2 2 2:title 'alpha on':rotate 50 60:box\nlight off:surf a";
smgl_alpha(mglGraph * gr)548 void smgl_alpha(mglGraph *gr)	// alpha and lighting
549 {
550 	mglData a;	mgls_prepare2d(&a);
551 	gr->SubPlot(2,2,0);	gr->Title("default");	gr->Rotate(50,60);
552 	gr->Box();	gr->Surf(a);
553 	gr->SubPlot(2,2,1);	gr->Title("light on");	gr->Rotate(50,60);
554 	gr->Box();	gr->Light(true);	gr->Surf(a);
555 	gr->SubPlot(2,2,3);	gr->Title("alpha on; light on");	gr->Rotate(50,60);
556 	gr->Box();	gr->Alpha(true);	gr->Surf(a);
557 	gr->SubPlot(2,2,2);	gr->Title("alpha on");	gr->Rotate(50,60);
558 	gr->Box();	gr->Light(false);	gr->Surf(a);
559 }
560 //-----------------------------------------------------------------------------
561 const char *mmgl_schemes="new x 100 100 'x':new y 100 100 'y'\n"
562 "call 'sch' 0 'kw'\ncall 'sch' 1 '%gbrw'\ncall 'sch' 2 'kHCcw'\ncall 'sch' 3 'kBbcw'\n"
563 "call 'sch' 4 'kRryw'\ncall 'sch' 5 'kGgew'\ncall 'sch' 6 'BbwrR'\ncall 'sch' 7 'BbwgG'\n"
564 "call 'sch' 8 'GgwmM'\ncall 'sch' 9 'UuwqR'\ncall 'sch' 10 'QqwcC'\ncall 'sch' 11 'CcwyY'\n"
565 "call 'sch' 12 'bcwyr'\ncall 'sch' 13 'bwr'\ncall 'sch' 14 'wUrqy'\ncall 'sch' 15 'UbcyqR'\n"
566 "call 'sch' 16 'BbcyrR'\ncall 'sch' 17 'bgr'\ncall 'sch' 18 'BbcyrR|'\ncall 'sch' 19 'b{g,0.3}r'\n"
567 "stop\nfunc 'sch' 2\nsubplot 2 10 $1 '<>_^' 0.2 0:surfa x y $2\n"
568 "text 0.07+0.5*mod($1,2) 0.92-0.1*int($1/2) $2 'A'\nreturn";
smgl_schemes(mglGraph * gr)569 void smgl_schemes(mglGraph *gr)	// Color table
570 {
571 	mglData a(256,2), b(256,2);	a.Fill(-1,1);	b.Fill(-1,1,'y');
572 	gr->SubPlot(2,10,0,NULL,0.2);	gr->Dens(a,"kw");		gr->Puts(0.07, 0.92, "kw", "A");
573 	gr->SubPlot(2,10,1,NULL,0.2);	gr->SurfA(a,b,"%gbrw");	gr->Puts(0.57, 0.92, "%gbrw", "A");
574 	gr->SubPlot(2,10,2,NULL,0.2);	gr->Dens(a,"kHCcw");	gr->Puts(0.07, 0.82, "kHCcw", "A");
575 	gr->SubPlot(2,10,3,NULL,0.2);	gr->Dens(a,"kBbcw");	gr->Puts(0.57, 0.82, "kBbcw", "A");
576 	gr->SubPlot(2,10,4,NULL,0.2);	gr->Dens(a,"kRryw");	gr->Puts(0.07, 0.72, "kRryw", "A");
577 	gr->SubPlot(2,10,5,NULL,0.2);	gr->Dens(a,"kGgew");	gr->Puts(0.57, 0.72, "kGgew", "A");
578 	gr->SubPlot(2,10,6,NULL,0.2);	gr->Dens(a,"BbwrR");	gr->Puts(0.07, 0.62, "BbwrR", "A");
579 	gr->SubPlot(2,10,7,NULL,0.2);	gr->Dens(a,"BbwgG");	gr->Puts(0.57, 0.62, "BbwgG", "A");
580 	gr->SubPlot(2,10,8,NULL,0.2);	gr->Dens(a,"GgwmM");	gr->Puts(0.07, 0.52, "GgwmM", "A");
581 	gr->SubPlot(2,10,9,NULL,0.2);	gr->Dens(a,"UuwqR");	gr->Puts(0.57, 0.52, "UuwqR", "A");
582 	gr->SubPlot(2,10,10,NULL,0.2);	gr->Dens(a,"QqwcC");	gr->Puts(0.07, 0.42, "QqwcC", "A");
583 	gr->SubPlot(2,10,11,NULL,0.2);	gr->Dens(a,"CcwyY");	gr->Puts(0.57, 0.42, "CcwyY", "A");
584 	gr->SubPlot(2,10,12,NULL,0.2);	gr->Dens(a,"bcwyr");	gr->Puts(0.07, 0.32, "bcwyr", "A");
585 	gr->SubPlot(2,10,13,NULL,0.2);	gr->Dens(a,"bwr");		gr->Puts(0.57, 0.32, "bwr", "A");
586 	gr->SubPlot(2,10,14,NULL,0.2);	gr->Dens(a,"wUrqy");	gr->Puts(0.07, 0.22, "wUrqy", "A");
587 	gr->SubPlot(2,10,15,NULL,0.2);	gr->Dens(a,"UbcyqR");	gr->Puts(0.57, 0.22, "UbcyqR", "A");
588 	gr->SubPlot(2,10,16,NULL,0.2);	gr->Dens(a,"BbcyrR");	gr->Puts(0.07, 0.12, "BbcyrR", "A");
589 	gr->SubPlot(2,10,17,NULL,0.2);	gr->Dens(a,"bgr");		gr->Puts(0.57, 0.12, "bgr", "A");
590 	gr->SubPlot(2,10,18,NULL,0.2);	gr->Dens(a,"BbcyrR|");	gr->Puts(0.07, 0.02, "BbcyrR|", "A");
591 	gr->SubPlot(2,10,19,NULL,0.2);	gr->Dens(a,"b{g,0.3}r");		gr->Puts(0.57, 0.02, "b\\{g,0.3\\}r", "A");
592 }
593 //-----------------------------------------------------------------------------
594 const char *mmgl_curvcoor="origin -1 1 -1\nsubplot 2 2 0:title 'Cartesian':rotate 50 60:fplot '2*t-1' '0.5' '0' '2r':axis:grid\n"
595 "axis 'y*sin(pi*x)' 'y*cos(pi*x)' '':subplot 2 2 1:title 'Cylindrical':rotate 50 60:fplot '2*t-1' '0.5' '0' '2r':axis:grid\n"
596 "axis '2*y*x' 'y*y - x*x' '':subplot 2 2 2:title 'Parabolic':rotate 50 60:fplot '2*t-1' '0.5' '0' '2r':axis:grid\n"
597 "axis 'y*sin(pi*x)' 'y*cos(pi*x)' 'x+z':subplot 2 2 3:title 'Spiral':rotate 50 60:fplot '2*t-1' '0.5' '0' '2r':axis:grid";
smgl_curvcoor(mglGraph * gr)598 void smgl_curvcoor(mglGraph *gr)	// curvilinear coordinates
599 {
600 	gr->SetOrigin(-1,1,-1);
601 
602 	gr->SubPlot(2,2,0);	gr->Title("Cartesian");	gr->Rotate(50,60);
603 	gr->FPlot("2*t-1","0.5","0","r2");
604 	gr->Axis(); gr->Grid();
605 
606 	gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)",0);
607 	gr->SubPlot(2,2,1);	gr->Title("Cylindrical");	gr->Rotate(50,60);
608 	gr->FPlot("2*t-1","0.5","0","r2");
609 	gr->Axis(); gr->Grid();
610 
611 	gr->SetFunc("2*y*x","y*y - x*x",0);
612 	gr->SubPlot(2,2,2);	gr->Title("Parabolic");	gr->Rotate(50,60);
613 	gr->FPlot("2*t-1","0.5","0","r2");
614 	gr->Axis(); gr->Grid();
615 
616 	gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)","x+z");
617 	gr->SubPlot(2,2,3);	gr->Title("Spiral");	gr->Rotate(50,60);
618 	gr->FPlot("2*t-1","0.5","0","r2");
619 	gr->Axis(); gr->Grid();
620 	gr->SetFunc(0,0,0);	// set to default Cartesian
621 }
622 //-----------------------------------------------------------------------------
623 const char *mmgl_style="";
smgl_style(mglGraph * gr)624 void smgl_style(mglGraph *gr)	// pen styles
625 {
626 	gr->SubPlot(2,2,0);
627 	double d,x1,x2,x0,y=1.1, y1=1.15;
628 	d=0.3, x0=0.2, x1=0.5, x2=0.6;
629 	gr->Line(mglPoint(x0,y1-0*d),mglPoint(x1,y1-0*d),"k-");	gr->Puts(mglPoint(x2,y-0*d),"Solid '-'",":rL");
630 	gr->Line(mglPoint(x0,y1-1*d),mglPoint(x1,y1-1*d),"k|");	gr->Puts(mglPoint(x2,y-1*d),"Long Dash '|'",":rL");
631 	gr->Line(mglPoint(x0,y1-2*d),mglPoint(x1,y1-2*d),"k;");	gr->Puts(mglPoint(x2,y-2*d),"Dash ';'",":rL");
632 	gr->Line(mglPoint(x0,y1-3*d),mglPoint(x1,y1-3*d),"k=");	gr->Puts(mglPoint(x2,y-3*d),"Small dash '='",":rL");
633 	gr->Line(mglPoint(x0,y1-4*d),mglPoint(x1,y1-4*d),"kj");	gr->Puts(mglPoint(x2,y-4*d),"Dash-dot 'j'",":rL");
634 	gr->Line(mglPoint(x0,y1-5*d),mglPoint(x1,y1-5*d),"ki");	gr->Puts(mglPoint(x2,y-5*d),"Small dash-dot 'i'",":rL");
635 	gr->Line(mglPoint(x0,y1-6*d),mglPoint(x1,y1-6*d),"k:");	gr->Puts(mglPoint(x2,y-6*d),"Dots ':'",":rL");
636 	gr->Line(mglPoint(x0,y1-7*d),mglPoint(x1,y1-7*d),"k ");	gr->Puts(mglPoint(x2,y-7*d),"None ' '",":rL");
637 	gr->Line(mglPoint(x0,y1-8*d),mglPoint(x1,y1-8*d),"k{df090}");	gr->Puts(mglPoint(x2,y-8*d),"Manual '{df090}'",":rL");
638 
639 	d=0.25; x1=-1; x0=-0.8;	y = -0.05;
640 	gr->Mark(mglPoint(x1,5*d),"k.");		gr->Puts(mglPoint(x0,y+5*d),"'.'",":rL");
641 	gr->Mark(mglPoint(x1,4*d),"k+");		gr->Puts(mglPoint(x0,y+4*d),"'+'",":rL");
642 	gr->Mark(mglPoint(x1,3*d),"kx");		gr->Puts(mglPoint(x0,y+3*d),"'x'",":rL");
643 	gr->Mark(mglPoint(x1,2*d),"k*");		gr->Puts(mglPoint(x0,y+2*d),"'*'",":rL");
644 	gr->Mark(mglPoint(x1,d),"ks");		gr->Puts(mglPoint(x0,y+d),"'s'",":rL");
645 	gr->Mark(mglPoint(x1,0),"kd");		gr->Puts(mglPoint(x0,y),"'d'",":rL");
646 	gr->Mark(mglPoint(x1,-d,0),"ko");	gr->Puts(mglPoint(x0,y-d),"'o'",":rL");
647 	gr->Mark(mglPoint(x1,-2*d,0),"k^");	gr->Puts(mglPoint(x0,y-2*d),"'\\^'",":rL");
648 	gr->Mark(mglPoint(x1,-3*d,0),"kv");	gr->Puts(mglPoint(x0,y-3*d),"'v'",":rL");
649 	gr->Mark(mglPoint(x1,-4*d,0),"k<");	gr->Puts(mglPoint(x0,y-4*d),"'<'",":rL");
650 	gr->Mark(mglPoint(x1,-5*d,0),"k>");	gr->Puts(mglPoint(x0,y-5*d),"'>'",":rL");
651 
652 	d=0.25; x1=-0.5; x0=-0.3;	y = -0.05;
653 	gr->Mark(mglPoint(x1,5*d),"k#.");	gr->Puts(mglPoint(x0,y+5*d),"'\\#.'",":rL");
654 	gr->Mark(mglPoint(x1,4*d),"k#+");	gr->Puts(mglPoint(x0,y+4*d),"'\\#+'",":rL");
655 	gr->Mark(mglPoint(x1,3*d),"k#x");	gr->Puts(mglPoint(x0,y+3*d),"'\\#x'",":rL");
656 	gr->Mark(mglPoint(x1,2*d),"k#*");	gr->Puts(mglPoint(x0,y+2*d),"'\\#*'",":rL");
657 	gr->Mark(mglPoint(x1,d),"k#s");		gr->Puts(mglPoint(x0,y+d),"'\\#s'",":rL");
658 	gr->Mark(mglPoint(x1,0),"k#d");		gr->Puts(mglPoint(x0,y),"'\\#d'",":rL");
659 	gr->Mark(mglPoint(x1,-d,0),"k#o");	gr->Puts(mglPoint(x0,y-d),"'\\#o'",":rL");
660 	gr->Mark(mglPoint(x1,-2*d,0),"k#^");	gr->Puts(mglPoint(x0,y-2*d),"'\\#\\^'",":rL");
661 	gr->Mark(mglPoint(x1,-3*d,0),"k#v");	gr->Puts(mglPoint(x0,y-3*d),"'\\#v'",":rL");
662 	gr->Mark(mglPoint(x1,-4*d,0),"k#<");	gr->Puts(mglPoint(x0,y-4*d),"'\\#<'",":rL");
663 	gr->Mark(mglPoint(x1,-5*d,0),"k#>");	gr->Puts(mglPoint(x0,y-5*d),"'\\#>'",":rL");
664 
665 	gr->SubPlot(2,2,1);
666 	double a=0.1,b=0.4,c=0.5;
667 	gr->Line(mglPoint(a,1),mglPoint(b,1),"k-A");		gr->Puts(mglPoint(c,1),"Style 'A' or 'A\\_'",":rL");
668 	gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"k-V");	gr->Puts(mglPoint(c,0.8),"Style 'V' or 'V\\_'",":rL");
669 	gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"k-K");	gr->Puts(mglPoint(c,0.6),"Style 'K' or 'K\\_'",":rL");
670 	gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"k-I");	gr->Puts(mglPoint(c,0.4),"Style 'I' or 'I\\_'",":rL");
671 	gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"k-D");	gr->Puts(mglPoint(c,0.2),"Style 'D' or 'D\\_'",":rL");
672 	gr->Line(mglPoint(a,0),mglPoint(b,0),"k-S");		gr->Puts(mglPoint(c,0),"Style 'S' or 'S\\_'",":rL");
673 	gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"k-O");	gr->Puts(mglPoint(c,-0.2),"Style 'O' or 'O\\_'",":rL");
674 	gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"k-T");	gr->Puts(mglPoint(c,-0.4),"Style 'T' or 'T\\_'",":rL");
675 	gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-X");	gr->Puts(mglPoint(c,-0.6),"Style 'X' or 'X\\_'",":rL");
676 	gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-_");	gr->Puts(mglPoint(c,-0.8),"Style '\\_' or none",":rL");
677 	gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-AS");		gr->Puts(mglPoint(c,-1),"Style 'AS'",":rL");
678 	gr->Line(mglPoint(a,-1.2),mglPoint(b,-1.2),"k-_A");	gr->Puts(mglPoint(c,-1.2),"Style '\\_A'",":rL");
679 
680 	a=-1;	b=-0.7;	c=-0.6;
681 	gr->Line(mglPoint(a,1),mglPoint(b,1),"kAA");		gr->Puts(mglPoint(c,1),"Style 'AA'",":rL");
682 	gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"kVV");	gr->Puts(mglPoint(c,0.8),"Style 'VV'",":rL");
683 	gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"kKK");	gr->Puts(mglPoint(c,0.6),"Style 'KK'",":rL");
684 	gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"kII");	gr->Puts(mglPoint(c,0.4),"Style 'II'",":rL");
685 	gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"kDD");	gr->Puts(mglPoint(c,0.2),"Style 'DD'",":rL");
686 	gr->Line(mglPoint(a,0),mglPoint(b,0),"kSS");		gr->Puts(mglPoint(c,0),"Style 'SS'",":rL");
687 	gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"kOO");	gr->Puts(mglPoint(c,-0.2),"Style 'OO'",":rL");
688 	gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"kTT");	gr->Puts(mglPoint(c,-0.4),"Style 'TT'",":rL");
689 	gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"kXX");	gr->Puts(mglPoint(c,-0.6),"Style 'XX'",":rL");
690 	gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-__");	gr->Puts(mglPoint(c,-0.8),"Style '\\_\\_'",":rL");
691 	gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-VA");		gr->Puts(mglPoint(c,-1),"Style 'VA'",":rL");
692 	gr->Line(mglPoint(a,-1.2),mglPoint(b,-1.2),"k-AV");	gr->Puts(mglPoint(c,-1.2),"Style 'AV'",":rL");
693 
694 	gr->SubPlot(2,2,2);
695 	//#LENUQ
696 	gr->FaceZ(mglPoint(-1,	-1), 0.4, 0.3, "L#");	gr->Puts(mglPoint(-0.8,-0.9), "L", "w:C", -1.4);
697 	gr->FaceZ(mglPoint(-0.6,-1), 0.4, 0.3, "E#");	gr->Puts(mglPoint(-0.4,-0.9), "E", "w:C", -1.4);
698 	gr->FaceZ(mglPoint(-0.2,-1), 0.4, 0.3, "N#");	gr->Puts(mglPoint(0,  -0.9), "N", "w:C", -1.4);
699 	gr->FaceZ(mglPoint(0.2,	-1), 0.4, 0.3, "U#");	gr->Puts(mglPoint(0.4,-0.9), "U", "w:C", -1.4);
700 	gr->FaceZ(mglPoint(0.6,	-1), 0.4, 0.3, "Q#");	gr->Puts(mglPoint(0.8,-0.9), "Q", "w:C", -1.4);
701 	//#lenuq
702 	gr->FaceZ(mglPoint(-1,	-0.7), 0.4, 0.3, "l#");	gr->Puts(mglPoint(-0.8,-0.6), "l", "k:C", -1.4);
703 	gr->FaceZ(mglPoint(-0.6,-0.7), 0.4, 0.3, "e#");	gr->Puts(mglPoint(-0.4,-0.6), "e", "k:C", -1.4);
704 	gr->FaceZ(mglPoint(-0.2,-0.7), 0.4, 0.3, "n#");	gr->Puts(mglPoint(0,  -0.6), "n", "k:C", -1.4);
705 	gr->FaceZ(mglPoint(0.2,	-0.7), 0.4, 0.3, "u#");	gr->Puts(mglPoint(0.4,-0.6), "u", "k:C", -1.4);
706 	gr->FaceZ(mglPoint(0.6,	-0.7), 0.4, 0.3, "q#");	gr->Puts(mglPoint(0.8,-0.6), "q", "k:C", -1.4);
707 	//#CMYkP
708 	gr->FaceZ(mglPoint(-1,	-0.4), 0.4, 0.3, "C#");	gr->Puts(mglPoint(-0.8,-0.3), "C", "w:C", -1.4);
709 	gr->FaceZ(mglPoint(-0.6,-0.4), 0.4, 0.3, "M#");	gr->Puts(mglPoint(-0.4,-0.3), "M", "w:C", -1.4);
710 	gr->FaceZ(mglPoint(-0.2,-0.4), 0.4, 0.3, "Y#");	gr->Puts(mglPoint(0,  -0.3), "Y", "w:C", -1.4);
711 	gr->FaceZ(mglPoint(0.2,	-0.4), 0.4, 0.3, "k#");	gr->Puts(mglPoint(0.4,-0.3), "k", "w:C", -1.4);
712 	gr->FaceZ(mglPoint(0.6,	-0.4), 0.4, 0.3, "P#");	gr->Puts(mglPoint(0.8,-0.3), "P", "w:C", -1.4);
713 	//#cmywp
714 	gr->FaceZ(mglPoint(-1,	-0.1), 0.4, 0.3, "c#");	gr->Puts(mglPoint(-0.8, 0), "c", "k:C", -1.4);
715 	gr->FaceZ(mglPoint(-0.6,-0.1), 0.4, 0.3, "m#");	gr->Puts(mglPoint(-0.4, 0), "m", "k:C", -1.4);
716 	gr->FaceZ(mglPoint(-0.2,-0.1), 0.4, 0.3, "y#");	gr->Puts(mglPoint(0,   0), "y", "k:C", -1.4);
717 	gr->FaceZ(mglPoint(0.2,	-0.1), 0.4, 0.3, "w#");	gr->Puts(mglPoint(0.4, 0), "w", "k:C", -1.4);
718 	gr->FaceZ(mglPoint(0.6,	-0.1), 0.4, 0.3, "p#");	gr->Puts(mglPoint(0.8, 0), "p", "k:C", -1.4);
719 	//#BGRHW
720 	gr->FaceZ(mglPoint(-1,	0.2), 0.4, 0.3, "B#");	gr->Puts(mglPoint(-0.8, 0.3), "B", "w:C", -1.4);
721 	gr->FaceZ(mglPoint(-0.6,0.2), 0.4, 0.3, "G#");	gr->Puts(mglPoint(-0.4, 0.3), "G", "w:C", -1.4);
722 	gr->FaceZ(mglPoint(-0.2,0.2), 0.4, 0.3, "R#");	gr->Puts(mglPoint(0,   0.3), "R", "w:C", -1.4);
723 	gr->FaceZ(mglPoint(0.2,	0.2), 0.4, 0.3, "H#");	gr->Puts(mglPoint(0.4, 0.3), "H", "w:C", -1.4);
724 	gr->FaceZ(mglPoint(0.6,	0.2), 0.4, 0.3, "W#");	gr->Puts(mglPoint(0.8, 0.3), "W", "w:C", -1.4);
725 	//#bgrhw
726 	gr->FaceZ(mglPoint(-1,	0.5), 0.4, 0.3, "b#");	gr->Puts(mglPoint(-0.8, 0.6), "b", "k:C", -1.4);
727 	gr->FaceZ(mglPoint(-0.6,0.5), 0.4, 0.3, "g#");	gr->Puts(mglPoint(-0.4, 0.6), "g", "k:C", -1.4);
728 	gr->FaceZ(mglPoint(-0.2,0.5), 0.4, 0.3, "r#");	gr->Puts(mglPoint(0,   0.6), "r", "k:C", -1.4);
729 	gr->FaceZ(mglPoint(0.2,	0.5), 0.4, 0.3, "h#");	gr->Puts(mglPoint(0.4, 0.6), "h", "k:C", -1.4);
730 	gr->FaceZ(mglPoint(0.6,	0.5), 0.4, 0.3, "w#");	gr->Puts(mglPoint(0.8, 0.6), "w", "k:C", -1.4);
731 	//#brighted
732 	gr->FaceZ(mglPoint(-1,	0.8), 0.4, 0.3, "{r1}#");	gr->Puts(mglPoint(-0.8, 0.9), "\\{r1\\}", "w:C", -1.4);
733 	gr->FaceZ(mglPoint(-0.6,0.8), 0.4, 0.3, "{r3}#");	gr->Puts(mglPoint(-0.4, 0.9), "\\{r3\\}", "w:C", -1.4);
734 	gr->FaceZ(mglPoint(-0.2,0.8), 0.4, 0.3, "{r5}#");	gr->Puts(mglPoint(0,   0.9), "\\{r5\\}", "k:C", -1.4);
735 	gr->FaceZ(mglPoint(0.2,	0.8), 0.4, 0.3, "{r7}#");	gr->Puts(mglPoint(0.4, 0.9), "\\{r7\\}", "k:C", -1.4);
736 	gr->FaceZ(mglPoint(0.6,	0.8), 0.4, 0.3, "{r9}#");	gr->Puts(mglPoint(0.8, 0.9), "\\{r9\\}", "k:C", -1.4);
737 	// HEX
738 	gr->FaceZ(mglPoint(-1, -1.3), 1, 0.3, "{xff9966}#");	gr->Puts(mglPoint(-0.5,-1.2), "\\{xff9966\\}", "k:C", -1.4);
739 	gr->FaceZ(mglPoint(0,  -1.3), 1, 0.3, "{x83CAFF}#");	gr->Puts(mglPoint( 0.5,-1.2), "\\{x83CAFF\\}", "k:C", -1.4);
740 
741 	gr->SubPlot(2,2,3);
742 	char stl[3]="r1", txt[4]="'1'";
743 	for(int i=0;i<10;i++)
744 	{
745 		txt[1]=stl[1]='0'+i;
746 		gr->Line(mglPoint(-1,0.2*i-1),mglPoint(1,0.2*i-1),stl);
747 		gr->Puts(mglPoint(1.05,0.2*i-1),txt,":L");
748 	}
749 }
750 //-----------------------------------------------------------------------------
751 const char *mmgl_text="call 'prepare1d'\nsubplot 2 2 0 ''\ntext 0 1 'Text can be in ASCII and in Unicode'\n"
752 "text 0 0.6 'It can be \\wire{wire}, \\big{big} or #r{colored}'\n"
753 "text 0 0.2 'One can change style in string: \\b{bold}, \\i{italic, \\b{both}}'\n"
754 "text 0 -0.2 'Easy to \\a{overline} or \\u{underline}'\n"
755 "text 0 -0.6 'Easy to change indexes ^{up} _{down} @{center}'\n"
756 "text 0 -1 'It parse TeX: \\int \\alpha \\cdot \\\n\\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx'\n"
757 "subplot 2 2 1 ''\n text 0 0.5 '\\sqrt{\\frac{\\alpha^{\\gamma^2}+\\overset 1{\\big\\infty}}{\\sqrt3{2+b}}}' '@' -2\n"
758 "text 0 -0.1 'More text position: \\frac{a}{b}, \\dfrac{a}{b}, [\\stack{a}{bbb}], [\\stackl{a}{bbb}], [\\stackr{a}{bbb}], \\sup{a}{sup}, \\sub{a}{sub}'"
759 "text 0 -0.5 'Text can be printed\\n{}on several lines'\n"
760 "text 0 -0.9 'or with color gradient' 'BbcyrR'\n"
761 "subplot 2 2 2 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k'\ntext y 'Another string drawn above a curve' 'Tr'\n"
762 "subplot 2 2 3 '':line -1 -1 1 -1 'rA':text 0 -1 1 -1 'Horizontal'\n"
763 "line -1 -1 1 1 'rA':text 0 0 1 1 'At angle' '@'\nline -1 -1 -1 1 'rA':text -1 0 -1 1 'Vertical'";
smgl_text(mglGraph * gr)764 void smgl_text(mglGraph *gr)	// text drawing
765 {
766 	if(big!=3)	gr->SubPlot(2,2,0,"");
767 	gr->Putsw(mglPoint(0,1),L"Text can be in ASCII and in Unicode");
768 	gr->Puts(mglPoint(0,0.6),"It can be \\wire{wire}, \\big{big} or #r{colored}");
769 	gr->Puts(mglPoint(0,0.2),"One can change style in string: "
770 	"\\b{bold}, \\i{italic, \\b{both}}");
771 	gr->Puts(mglPoint(0,-0.2),"Easy to \\a{overline} or "
772 	"\\u{underline}");
773 	gr->Puts(mglPoint(0,-0.6),"Easy to change indexes ^{up} _{down} @{center}");
774 	gr->Puts(mglPoint(0,-1),"It parse TeX: \\int \\alpha \\cdot "
775 	"\\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx");
776 	if(big==3)	return;
777 
778 	gr->SubPlot(2,2,1,"");
779 	gr->Puts(mglPoint(0,0.5), "\\sqrt{\\frac{\\alpha^{\\gamma^2}+\\overset 1{\\big\\infty}}{\\sqrt3{2+b}}}", "@", -2);
780 	gr->Puts(mglPoint(0,-0.1),"More text position: \\frac{a}{b}, \\dfrac{a}{b}, [\\stack{a}{bbb}], [\\stackl{a}{bbb}], [\\stackr{a}{bbb}], \\sup{a}{sup}, \\sub{a}{sub}");
781 	gr->Puts(mglPoint(0,-0.5),"Text can be printed\non several lines");
782 	gr->Puts(mglPoint(0,-0.9),"or with col\bor gradient","BbcyrR");
783 
784 	gr->SubPlot(2,2,2,"");
785 	mglData y;	mgls_prepare1d(&y);
786 	gr->Box();	gr->Plot(y.SubData(-1,0));
787 	gr->Text(y,"This is very very long string drawn along a curve","k");
788 	gr->Text(y,"Another string drawn under a curve","Tr");
789 
790 	gr->SubPlot(2,2,3,"");
791 	gr->Line(mglPoint(-1,-1),mglPoint(1,-1),"rA");	gr->Puts(mglPoint(0,-1),mglPoint(1,-1),"Horizontal");
792 	gr->Line(mglPoint(-1,-1),mglPoint(1,1),"rA");	gr->Puts(mglPoint(0,0),mglPoint(1,1),"At angle","@");
793 	gr->Line(mglPoint(-1,-1),mglPoint(-1,1),"rA");	gr->Puts(mglPoint(-1,0),mglPoint(-1,1),"Vertical");
794 }
795 //-----------------------------------------------------------------------------
796 const char *mmgl_text2="call 'prepare1d'\n"
797 "subplot 1 3 0 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k'\ntext y 'Another string drawn under a curve' 'Tr'\n"
798 "subplot 1 3 1 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k:C'\ntext y 'Another string drawn under a curve' 'Tr:C'\n"
799 "subplot 1 3 2 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k:R'\ntext y 'Another string drawn under a curve' 'Tr:R'";
smgl_text2(mglGraph * gr)800 void smgl_text2(mglGraph *gr)	// text drawing
801 {
802 	mglData y;	mgls_prepare1d(&y);
803 	if(big!=3)	gr->SubPlot(1,3,0,"");
804 	gr->Box();	gr->Plot(y.SubData(-1,0));
805 	gr->Text(y,"This is very very long string drawn along a curve","k");
806 	gr->Text(y,"Another string drawn under a curve","Tr");
807 	if(big==3)	return;
808 
809 	gr->SubPlot(1,3,1,"");
810 	gr->Box();	gr->Plot(y.SubData(-1,0));
811 	gr->Text(y,"This is very very long string drawn along a curve","k:C");
812 	gr->Text(y,"Another string drawn under a curve","Tr:C");
813 
814 	gr->SubPlot(1,3,2,"");
815 	gr->Box();	gr->Plot(y.SubData(-1,0));
816 	gr->Text(y,"This is very very long string drawn along a curve","k:R");
817 	gr->Text(y,"Another string drawn under a curve","Tr:R");
818 }
819 //-----------------------------------------------------------------------------
820 const char *mmgl_fonts="define d 0.25\nloadfont 'STIX':text 0 1.1 'default font (STIX)'\nloadfont 'adventor':text 0 1.1-d 'adventor font'\n"
821 "loadfont 'bonum':text 0 1.1-2*d 'bonum font'\nloadfont 'chorus':text 0 1.1-3*d 'chorus font'\nloadfont 'cursor':text 0 1.1-4*d 'cursor font'\n"
822 "loadfont 'heros':text 0 1.1-5*d 'heros font'\nloadfont 'heroscn':text 0 1.1-6*d 'heroscn font'\nloadfont 'pagella':text 0 1.1-7*d 'pagella font'\n"
823 "loadfont 'schola':text 0 1.1-8*d 'schola font'\nloadfont 'termes':text 0 1.1-9*d 'termes font'\nloadfont ''";
smgl_fonts(mglGraph * gr)824 void smgl_fonts(mglGraph *gr)	// font typefaces
825 {
826 	double h=1.1, d=0.25;
827 	gr->LoadFont("STIX");		gr->Puts(mglPoint(0,h), "default font (STIX)");
828 	gr->LoadFont("adventor");	gr->Puts(mglPoint(0,h-d), "adventor font");
829 	gr->LoadFont("bonum");		gr->Puts(mglPoint(0,h-2*d), "bonum font");
830 	gr->LoadFont("chorus");		gr->Puts(mglPoint(0,h-3*d), "chorus font");
831 	gr->LoadFont("cursor");		gr->Puts(mglPoint(0,h-4*d), "cursor font");
832 	gr->LoadFont("heros");		gr->Puts(mglPoint(0,h-5*d), "heros font");
833 	gr->LoadFont("heroscn");	gr->Puts(mglPoint(0,h-6*d), "heroscn font");
834 	gr->LoadFont("pagella");	gr->Puts(mglPoint(0,h-7*d), "pagella font");
835 	gr->LoadFont("schola");		gr->Puts(mglPoint(0,h-8*d), "schola font");
836 	gr->LoadFont("termes");		gr->Puts(mglPoint(0,h-9*d), "termes font");
837 	gr->LoadFont("");
838 }
839 //-----------------------------------------------------------------------------
840 const char *mmgl_background="define $f udav_new.png\n#background '$f' 's'\n"
841 "subplot 2 2 0 '':box\nbackground '$f' 'a'\ntext 0.5 0.1 'Default' 'a'\n"
842 "subplot 2 2 1 '':box\nbackground '$f' 'ca'\ntext 0.5 0.1 'Centering' 'a'\n"
843 "subplot 2 2 2 '':box\nbackground '$f' 'ma'\ntext 0.5 0.1 'Mosaic' 'a'\n"
844 "subplot 2 2 3 '':box\nbackground '$f' 'sa'\ntext 0.5 0.1 'Scaling' 'a'";
smgl_background(mglGraph * gr)845 void smgl_background(mglGraph *gr)
846 {
847 	const char *fname = "udav_new.png";
848 	gr->SubPlot(2,2,0,"");	gr->Box();	gr->LoadBackground(fname,"a");	gr->Puts(0.5,0.1,"Default","a");
849 	gr->SubPlot(2,2,1,"");	gr->Box();	gr->LoadBackground(fname,"ca");	gr->Puts(0.5,0.1,"Centering","a");
850 	gr->SubPlot(2,2,2,"");	gr->Box();	gr->LoadBackground(fname,"ma");	gr->Puts(0.5,0.1,"Mosaic","a");
851 	gr->SubPlot(2,2,3,"");	gr->Box();	gr->LoadBackground(fname,"sa");	gr->Puts(0.5,0.1,"Scaling","a");
852 	//gr->LoadBackground(fname,"s");
853 }
854 //-----------------------------------------------------------------------------
855 const char *mmgl_bars="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd':origin 0 0 0\n"
856 "subplot 3 2 0 '':title 'Bars plot (default)':box:bars ys\nsubplot 3 2 1 '':title '2 colors':box:bars ys 'cbgGyr'\n"
857 "subplot 3 2 4 '':title '\"\\#\" style':box:bars ys '#'\n"
858 "new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 3 2 5:title '3d variant':rotate 50 60:box:bars xc yc z 'r'\n"
859 "ranges -1 1 -3 3:subplot 3 2 2 '':title '\"a\" style':box:bars ys 'a'\nsubplot 3 2 3 '':title '\"f\" style':box:bars ys 'f'";
smgl_bars(mglGraph * gr)860 void smgl_bars(mglGraph *gr)
861 {
862 	mglData ys(10,3);	ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
863 	gr->SetOrigin(0,0,0);
864 	if(big!=3)	{	gr->SubPlot(3,2,0,"");	gr->Title("Bars plot (default)");	}
865 	gr->Box();	gr->Bars(ys);
866 	if(big==3)	return;
867 	gr->SubPlot(3,2,1,"");	gr->Title("2 colors");	gr->Box();	gr->Bars(ys,"cbgGyr");
868 	gr->SubPlot(3,2,4,"");	gr->Title("'\\#' style");	gr->Box();	gr->Bars(ys,"#");
869 	gr->SubPlot(3,2,5);	gr->Title("3d variant");	gr->Rotate(50,60);	gr->Box();
870 	mglData yc(30), xc(30), z(30);	z.Modify("2*x-1");
871 	yc.Modify("sin(pi*(2*x-1))");	xc.Modify("cos(pi*2*x-pi)");
872 	gr->Bars(xc,yc,z,"r");
873 	gr->SetRanges(-1,1,-3,3);	// increase range since summation can exceed [-1,1]
874 	gr->SubPlot(3,2,2,"");	gr->Title("'a' style");	gr->Box();	gr->Bars(ys,"a");
875 	gr->SubPlot(3,2,3,"");	gr->Title("'f' style");	gr->Box();	gr->Bars(ys,"f");
876 }
877 //-----------------------------------------------------------------------------
878 const char *mmgl_barh="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd':origin 0 0 0\n"
879 "subplot 2 2 0 '':title 'Barh plot (default)':box:barh ys\nsubplot 2 2 1 '':title '2 colors':box:barh ys 'cbgGyr'\n"
880 "ranges -3 3 -1 1:subplot 2 2 2 '':title '\"a\" style':box:barh ys 'a'\nsubplot 2 2 3 '': title '\"f\" style':box:barh ys 'f'";
smgl_barh(mglGraph * gr)881 void smgl_barh(mglGraph *gr)
882 {
883 	mglData ys(10,3);	ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
884 	gr->SetOrigin(0,0,0);
885 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Barh plot (default)");	}
886 	gr->Box();	gr->Barh(ys);
887 	if(big==3)	return;
888 	gr->SubPlot(2,2,1,"");	gr->Title("2 colors");	gr->Box();	gr->Barh(ys,"cbgGyr");
889 	gr->SetRanges(-3,3,-1,1);	// increase range since summation can exceed [-1,1]
890 	gr->SubPlot(2,2,2,"");	gr->Title("'a' style");	gr->Box();	gr->Barh(ys,"a");
891 	gr->SubPlot(2,2,3,"");	gr->Title("'f' style");	gr->Box();	gr->Barh(ys,"f");
892 }
893 //-----------------------------------------------------------------------------
894 const char *mmgl_area="call 'prepare1d'\norigin 0 0 0\nsubplot 2 2 0 '':title 'Area plot (default)':box:area y\n"
895 "subplot 2 2 1 '':title '2 colors':box:area y 'cbgGyr'\nsubplot 2 2 2 '':title '\"!\" style':box:area y '!'\n"
896 "new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 2 2 3:title '3d variant':rotate 50 60:box\n"
897 "area xc yc z 'r'\narea xc -yc z 'b#'";
smgl_area(mglGraph * gr)898 void smgl_area(mglGraph *gr)
899 {
900 	mglData y;	mgls_prepare1d(&y);	gr->SetOrigin(0,0,0);
901 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Area plot (default)");	}
902 	gr->Box();	gr->Area(y);
903 	if(big==3)	return;
904 	gr->SubPlot(2,2,1,"");	gr->Title("2 colors");	gr->Box();	gr->Area(y,"cbgGyr");
905 	gr->SubPlot(2,2,2,"");	gr->Title("'!' style");	gr->Box();	gr->Area(y,"!");
906 	gr->SubPlot(2,2,3);	gr->Title("3d variant");	gr->Rotate(50,60);	gr->Box();
907 	mglData yc(30), xc(30), z(30);	z.Modify("2*x-1");
908 	yc.Modify("sin(pi*(2*x-1))");	xc.Modify("cos(pi*2*x-pi)");
909 	gr->Area(xc,yc,z,"r");
910 	yc.Modify("-sin(pi*(2*x-1))");	gr->Area(xc,yc,z,"b#");
911 }
912 //-----------------------------------------------------------------------------
913 const char *mmgl_plot="call 'prepare1d'\nsubplot 2 2 0 '':title 'Plot plot (default)':box:plot y\n"
914 "subplot 2 2 2 '':title ''!' style; 'rgb' palette':box:plot y 'o!rgb'\nsubplot 2 2 3 '':title 'just markers':box:plot y ' +'\n"
915 "new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 2 2 1:title '3d variant':rotate 50 60:box:plot xc yc z 'rs'";
smgl_plot(mglGraph * gr)916 void smgl_plot(mglGraph *gr)
917 {
918 	mglData y;	mgls_prepare1d(&y);	gr->SetOrigin(0,0,0);
919 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Plot plot (default)");	}
920 	gr->Box();	gr->Plot(y);
921 	if(big==3)	return;
922 	gr->SubPlot(2,2,2,"");	gr->Title("'!' style; 'rgb' palette");	gr->Box();	gr->Plot(y,"o!rgb");
923 	gr->SubPlot(2,2,3,"");	gr->Title("just markers");	gr->Box();	gr->Plot(y," +");
924 	gr->SubPlot(2,2,1);	gr->Title("3d variant");	gr->Rotate(50,60);	gr->Box();
925 	mglData yc(30), xc(30), z(30);	z.Modify("2*x-1");
926 	yc.Modify("sin(pi*(2*x-1))");	xc.Modify("cos(pi*2*x-pi)");
927 	gr->Plot(xc,yc,z,"rs");
928 }
929 //-----------------------------------------------------------------------------
930 const char *mmgl_tens="call 'prepare1d'\nsubplot 2 2 0 '':title 'Tens plot (default)':box:tens y(:,0) y(:,1)\n"
931 "subplot 2 2 2 '':title '\" \" style':box:tens y(:,0) y(:,1) 'o '\n"
932 "new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\n"
933 "subplot 2 2 1:title '3d variant':rotate 50 60:box:tens xc yc z z 's'";
smgl_tens(mglGraph * gr)934 void smgl_tens(mglGraph *gr)
935 {
936 	mglData y;	mgls_prepare1d(&y);	gr->SetOrigin(0,0,0);
937 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Tens plot (default)");	}
938 	gr->Box();	gr->Tens(y.SubData(-1,0), y.SubData(-1,1));
939 	if(big==3)	return;
940 	gr->SubPlot(2,2,2,"");	gr->Title("' ' style");	gr->Box();	gr->Tens(y.SubData(-1,0), y.SubData(-1,1),"o ");
941 	gr->SubPlot(2,2,1);	gr->Title("3d variant");	gr->Rotate(50,60);	gr->Box();
942 	mglData yc(30), xc(30), z(30);	z.Modify("2*x-1");
943 	yc.Modify("sin(pi*(2*x-1))");	xc.Modify("cos(pi*2*x-pi)");
944 	gr->Tens(xc,yc,z,z,"s");
945 }
946 //-----------------------------------------------------------------------------
947 const char *mmgl_region="call 'prepare1d'\ncopy y1 y(:,1):copy y2 y(:,2)\n"
948 "subplot 2 2 0 '':title 'Region plot (default)':box:region y1 y2:plot y1 'k2':plot y2 'k2'\n"
949 "subplot 2 2 1 '':title '2 colors':box:region y1 y2 'yr':plot y1 'k2':plot y2 'k2'\n"
950 "subplot 2 2 2 '':title '\"i\" style':box:region y1 y2 'ir':plot y1 'k2':plot y2 'k2'\n"
951 "subplot 2 2 3 '^_':title '3d variant':rotate 40 60:box\n"
952 "new x1 100 'sin(pi*x)':new y1 100 'cos(pi*x)':new z 100 'x'\n"
953 "new x2 100 'sin(pi*x+pi/3)':new y2 100 'cos(pi*x+pi/3)'\n"
954 "plot x1 y1 z 'r2':plot x2 y2 z 'b2'\nregion x1 y1 z x2 y2 z 'cmy!'";
smgl_region(mglGraph * gr)955 void smgl_region(mglGraph *gr)
956 {
957 	mglData y;	mgls_prepare1d(&y);
958 	mglData y1 = y.SubData(-1,1), y2 = y.SubData(-1,2);	gr->SetOrigin(0,0,0);
959 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Region plot (default)");	}
960 	gr->Box();	gr->Region(y1,y2);	gr->Plot(y1,"k2");	gr->Plot(y2,"k2");
961 	if(big==3)	return;
962 	gr->SubPlot(2,2,1,"");	gr->Title("2 colors");	gr->Box();	gr->Region(y1,y2,"yr");	gr->Plot(y1,"k2");	gr->Plot(y2,"k2");
963 	gr->SubPlot(2,2,2,"");	gr->Title("'i' style");	gr->Box();	gr->Region(y1,y2,"ir");	gr->Plot(y1,"k2");	gr->Plot(y2,"k2");
964 	gr->SubPlot(2,2,3,"^_");	gr->Title("3d variant");	gr->Rotate(40,60);	gr->Box();
965 	gr->Fill(y1,"cos(pi*x)");	gr->Fill(y2,"cos(pi*x+pi/3)");
966 	mglData x1(y1.nx), x2(y1.nx), z(y1.nx);
967 	gr->Fill(x1,"sin(pi*x)");	gr->Fill(x2,"sin(pi*x+pi/3)");	gr->Fill(z,"x");
968 	gr->Plot(x1,y1,z,"r2");		gr->Plot(x2,y2,z,"b2");
969 	gr->Region(x1,y1,z,x2,y2,z,"cmy!");
970 }
971 //-----------------------------------------------------------------------------
972 const char *mmgl_stem="call 'prepare1d'\norigin 0 0 0:subplot 2 2 0 '':title 'Stem plot (default)':box:stem y\n"
973 "new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 2 2 1:title '3d variant':rotate 50 60:box:stem xc yc z 'rx'\n"
974 "subplot 2 2 2 '':title '\"!\" style':box:stem y 'o!rgb'";
smgl_stem(mglGraph * gr)975 void smgl_stem(mglGraph *gr)
976 {
977 	mglData y;	mgls_prepare1d(&y);	gr->SetOrigin(0,0,0);
978 	mglData yc(30), xc(30), z(30);	z.Modify("2*x-1");
979 	yc.Modify("sin(pi*(2*x-1))");	xc.Modify("cos(pi*2*x-pi)");
980 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Stem plot (default)");	}
981 	gr->Box();	gr->Stem(y);
982 	if(big==3)	return;
983 	gr->SubPlot(2,2,1);	gr->Title("3d variant");	gr->Rotate(50,60);
984 	gr->Box();	gr->Stem(xc,yc,z,"rx");
985 	gr->SubPlot(2,2,2,"");	gr->Title("'!' style");	gr->Box();	gr->Stem(y,"o!rgb");
986 }
987 //-----------------------------------------------------------------------------
988 const char *mmgl_step="call 'prepare1d'\norigin 0 0 0:subplot 2 2 0 '':title 'Step plot (default)':box:step y\n"
989 "new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 2 2 1:title '3d variant':rotate 50 60:box:step xc yc z 'r'\n"
990 "subplot 2 2 2 '':title '\"!\" style':box:step y 's!rgb'";
smgl_step(mglGraph * gr)991 void smgl_step(mglGraph *gr)
992 {
993 	mglData y;	mgls_prepare1d(&y);	gr->SetOrigin(0,0,0);
994 	mglData yc(30), xc(30), z(30);	z.Modify("2*x-1");
995 	yc.Modify("sin(pi*(2*x-1))");	xc.Modify("cos(pi*2*x-pi)");
996 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Step plot (default)");	}
997 	gr->Box();	gr->Step(y);
998 	if(big==3)	return;
999 	gr->SubPlot(2,2,1);	gr->Title("3d variant");	gr->Rotate(50,60);
1000 	gr->Box();	gr->Step(xc,yc,z,"r");
1001 	gr->SubPlot(2,2,2,"");	gr->Title("'!' style");	gr->Box();	gr->Step(y,"s!rgb");
1002 }
1003 //-----------------------------------------------------------------------------
1004 const char *mmgl_boxplot="new a 10 7 '(2*rnd-1)^3/2'\nsubplot 1 1 0 '':title 'Boxplot plot':box:boxplot a";
smgl_boxplot(mglGraph * gr)1005 void smgl_boxplot(mglGraph *gr)	// flow threads and density plot
1006 {
1007 	mglData a(10,7);	a.Modify("(2*rnd-1)^3/2");
1008 	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("Boxplot plot");	}
1009 	gr->Box();	gr->BoxPlot(a);
1010 }
1011 //-----------------------------------------------------------------------------
1012 const char *mmgl_ohlc="new o 10 '0.5*sin(pi*x)'\nnew c 10 '0.5*sin(pi*(x+2/9))'\n"
1013 "new l 10 '0.3*rnd-0.8'\nnew h 10 '0.3*rnd+0.5'\n"
1014 "subplot 1 1 0 '':title 'OHLC plot':box:ohlc o h l c";
smgl_ohlc(mglGraph * gr)1015 void smgl_ohlc(mglGraph *gr)	// flow threads and density plot
1016 {
1017 	mglData o(10), h(10), l(10), c(10);
1018 	gr->Fill(o,"0.5*sin(pi*x)");	gr->Fill(c,"0.5*sin(pi*(x+2/9))");
1019 	gr->Fill(l,"0.3*rnd-0.8");		gr->Fill(h,"0.3*rnd+0.5");
1020 	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("OHLC plot");	}
1021 	gr->Box();	gr->OHLC(o,h,l,c);
1022 }
1023 //-----------------------------------------------------------------------------
1024 const char *mmgl_type0="call 'prepare2d'\nalpha on:light on:transptype 0:clf\nsubplot 2 2 0:rotate 50 60:surf a:box\n"
1025 "subplot 2 2 1:rotate 50 60:dens a:box\nsubplot 2 2 2:rotate 50 60:cont a:box\n"
1026 "subplot 2 2 3:rotate 50 60:axial a:box";
smgl_type0(mglGraph * gr)1027 void smgl_type0(mglGraph *gr)	// TranspType = 0
1028 {
1029 	gr->Alpha(true);	gr->Light(true);
1030 	mglData a;	mgls_prepare2d(&a);
1031 	gr->SetTranspType(0);	gr->Clf();
1032 	gr->SubPlot(2,2,0);	gr->Rotate(50,60);	gr->Surf(a);	gr->Box();
1033 	gr->SubPlot(2,2,1);	gr->Rotate(50,60);	gr->Dens(a);	gr->Box();
1034 	gr->SubPlot(2,2,2);	gr->Rotate(50,60);	gr->Cont(a);	gr->Box();
1035 	gr->SubPlot(2,2,3);	gr->Rotate(50,60);	gr->Axial(a);	gr->Box();
1036 }
1037 //-----------------------------------------------------------------------------
1038 const char *mmgl_type1="call 'prepare2d'\nalpha on:light on:transptype 1:clf\nsubplot 2 2 0:rotate 50 60:surf a:box\n"
1039 "subplot 2 2 1:rotate 50 60:dens a:box\nsubplot 2 2 2:rotate 50 60:cont a:box\n"
1040 "subplot 2 2 3:rotate 50 60:axial a:box";
smgl_type1(mglGraph * gr)1041 void smgl_type1(mglGraph *gr)	// TranspType = 1
1042 {
1043 	gr->Alpha(true);	gr->Light(true);
1044 	mglData a;	mgls_prepare2d(&a);
1045 	gr->SetTranspType(1);	gr->Clf();
1046 	gr->SubPlot(2,2,0);	gr->Rotate(50,60);	gr->Surf(a);	gr->Box();
1047 	gr->SubPlot(2,2,1);	gr->Rotate(50,60);	gr->Dens(a);	gr->Box();
1048 	gr->SubPlot(2,2,2);	gr->Rotate(50,60);	gr->Cont(a);	gr->Box();
1049 	gr->SubPlot(2,2,3);	gr->Rotate(50,60);	gr->Axial(a);	gr->Box();
1050 }
1051 //-----------------------------------------------------------------------------
1052 const char *mmgl_type2="call 'prepare2d'\nalpha on:light on:transptype 2:clf\nsubplot 2 2 0:rotate 50 60:surf a:box\n"
1053 "subplot 2 2 1:rotate 50 60:dens a:box\nsubplot 2 2 2:rotate 50 60:cont a:box\n"
1054 "subplot 2 2 3:rotate 50 60:axial a:box";
smgl_type2(mglGraph * gr)1055 void smgl_type2(mglGraph *gr)	// TranspType = 2
1056 {
1057 	gr->Alpha(true);	gr->Light(true);
1058 	mglData a;	mgls_prepare2d(&a);
1059 	gr->SetTranspType(2);	gr->Clf();
1060 	gr->SubPlot(2,2,0);	gr->Rotate(50,60);	gr->Surf(a);	gr->Box();
1061 	gr->SubPlot(2,2,1);	gr->Rotate(50,60);	gr->Dens(a);	gr->Box();
1062 	gr->SubPlot(2,2,2);	gr->Rotate(50,60);	gr->Cont(a);	gr->Box();
1063 	gr->SubPlot(2,2,3);	gr->Rotate(50,60);	gr->Axial(a);	gr->Box();
1064 }
1065 //-----------------------------------------------------------------------------
1066 const char *mmgl_molecule="alpha on:light on\n"
1067 "subplot 2 2 0 '':title 'Methane, CH_4':rotate 60 120\n"
1068 "sphere 0 0 0 0.25 'k':drop 0 0 0 0 0 1 0.35 'h' 1 2:sphere 0 0 0.7 0.25 'g'\n"
1069 "drop 0 0 0 -0.94 0 -0.33 0.35 'h' 1 2:sphere -0.66 0 -0.23 0.25 'g'\n"
1070 "drop 0 0 0 0.47 0.82 -0.33 0.35 'h' 1 2:sphere 0.33 0.57 -0.23 0.25 'g'\n"
1071 "drop 0 0 0 0.47 -0.82 -0.33 0.35 'h' 1 2:sphere 0.33 -0.57 -0.23 0.25 'g'\n"
1072 "subplot 2 2 1 '':title 'Water, H{_2}O':rotate 60 100\n"
1073 "sphere 0 0 0 0.25 'r':drop 0 0 0 0.3 0.5 0 0.3 'm' 1 2:sphere 0.3 0.5 0 0.25 'g'\n"
1074 "drop 0 0 0 0.3 -0.5 0 0.3 'm' 1 2:sphere 0.3 -0.5 0 0.25 'g'\n"
1075 "subplot 2 2 2 '':title 'Oxygen, O_2':rotate 60 120\n"
1076 "drop 0 0.5 0 0 -0.3 0 0.3 'm' 1 2:sphere 0 0.5 0 0.25 'r'\n"
1077 "drop 0 -0.5 0 0 0.3 0 0.3 'm' 1 2:sphere 0 -0.5 0 0.25 'r'\n"
1078 "subplot 2 2 3 '':title 'Ammonia, NH_3':rotate 60 120\n"
1079 "sphere 0 0 0 0.25 'b':drop 0 0 0 0.33 0.57 0 0.32 'n' 1 2\n"
1080 "sphere 0.33 0.57 0 0.25 'g':drop 0 0 0 0.33 -0.57 0 0.32 'n' 1 2\n"
1081 "sphere 0.33 -0.57 0 0.25 'g':drop 0 0 0 -0.65 0 0 0.32 'n' 1 2\n"
1082 "sphere -0.65 0 0 0.25 'g'";
smgl_molecule(mglGraph * gr)1083 void smgl_molecule(mglGraph *gr)	// example of moleculas
1084 {
1085 	gr->VertexColor(false);	gr->Compression(false); // per-vertex colors and compression are detrimental to transparency
1086 	gr->DoubleSided(false); // we do not get into atoms, while rendering internal surface has negative impact on trasparency
1087 	gr->Alpha(true);	gr->Light(true);
1088 
1089 	gr->SubPlot(2,2,0,"");	gr->Title("Methane, CH_4");
1090 	gr->StartGroup("Methane");
1091 	gr->Rotate(60,120);
1092 	gr->Sphere(mglPoint(0,0,0),0.25,"k");
1093 	gr->Drop(mglPoint(0,0,0),mglPoint(0,0,1),0.35,"h",1,2);
1094 	gr->Sphere(mglPoint(0,0,0.7),0.25,"g");
1095 	gr->Drop(mglPoint(0,0,0),mglPoint(-0.94,0,-0.33),0.35,"h",1,2);
1096 	gr->Sphere(mglPoint(-0.66,0,-0.23),0.25,"g");
1097 	gr->Drop(mglPoint(0,0,0),mglPoint(0.47,0.82,-0.33),0.35,"h",1,2);
1098 	gr->Sphere(mglPoint(0.33,0.57,-0.23),0.25,"g");
1099 	gr->Drop(mglPoint(0,0,0),mglPoint(0.47,-0.82,-0.33),0.35,"h",1,2);
1100 	gr->Sphere(mglPoint(0.33,-0.57,-0.23),0.25,"g");
1101 	gr->EndGroup();
1102 
1103 	gr->SubPlot(2,2,1,"");	gr->Title("Water, H_{2}O");
1104 	gr->StartGroup("Water");
1105 	gr->Rotate(60,100);
1106 	gr->StartGroup("Water_O");
1107 	gr->Sphere(mglPoint(0,0,0),0.25,"r");
1108 	gr->EndGroup();
1109 	gr->StartGroup("Water_Bond_1");
1110 	gr->Drop(mglPoint(0,0,0),mglPoint(0.3,0.5,0),0.3,"m",1,2);
1111 	gr->EndGroup();
1112 	gr->StartGroup("Water_H_1");
1113 	gr->Sphere(mglPoint(0.3,0.5,0),0.25,"g");
1114 	gr->EndGroup();
1115 	gr->StartGroup("Water_Bond_2");
1116 	gr->Drop(mglPoint(0,0,0),mglPoint(0.3,-0.5,0),0.3,"m",1,2);
1117 	gr->EndGroup();
1118 	gr->StartGroup("Water_H_2");
1119 	gr->Sphere(mglPoint(0.3,-0.5,0),0.25,"g");
1120 	gr->EndGroup();
1121 	gr->EndGroup();
1122 
1123 	gr->SubPlot(2,2,2,"");	gr->Title("Oxygen, O_2");
1124 	gr->StartGroup("Oxygen");
1125 	gr->Rotate(60,120);
1126 	gr->Drop(mglPoint(0,0.5,0),mglPoint(0,-0.3,0),0.3,"m",1,2);
1127 	gr->Sphere(mglPoint(0,0.5,0),0.25,"r");
1128 	gr->Drop(mglPoint(0,-0.5,0),mglPoint(0,0.3,0),0.3,"m",1,2);
1129 	gr->Sphere(mglPoint(0,-0.5,0),0.25,"r");
1130 	gr->EndGroup();
1131 
1132 	gr->SubPlot(2,2,3,"");	gr->Title("Ammonia, NH_3");
1133 	gr->StartGroup("Ammonia");
1134 	gr->Rotate(60,120);
1135 	gr->Sphere(mglPoint(0,0,0),0.25,"b");
1136 	gr->Drop(mglPoint(0,0,0),mglPoint(0.33,0.57,0),0.32,"n",1,2);
1137 	gr->Sphere(mglPoint(0.33,0.57,0),0.25,"g");
1138 	gr->Drop(mglPoint(0,0,0),mglPoint(0.33,-0.57,0),0.32,"n",1,2);
1139 	gr->Sphere(mglPoint(0.33,-0.57,0),0.25,"g");
1140 	gr->Drop(mglPoint(0,0,0),mglPoint(-0.65,0,0),0.32,"n",1,2);
1141 	gr->Sphere(mglPoint(-0.65,0,0),0.25,"g");
1142 	gr->EndGroup();
1143 	gr->DoubleSided( true ); // put back
1144 }
1145 //-----------------------------------------------------------------------------
1146 const char *mmgl_error2="new x0 10 'rnd':new ex 10 '0.1'\nnew y0 10 'rnd':new ey 10 '0.1'\nranges 0 1 0 1\n"
1147 "subplot 4 3 0 '':box:error x0 y0 ex ey '#+@'\n"
1148 "subplot 4 3 1 '':box:error x0 y0 ex ey '#x@'\n"
1149 "subplot 4 3 2 '':box:error x0 y0 ex ey '#s@'; alpha 0.5\n"
1150 "subplot 4 3 3 '':box:error x0 y0 ex ey 's@'\n"
1151 "subplot 4 3 4 '':box:error x0 y0 ex ey 'd@'\n"
1152 "subplot 4 3 5 '':box:error x0 y0 ex ey '#d@'; alpha 0.5\n"
1153 "subplot 4 3 6 '':box:error x0 y0 ex ey '+@'\n"
1154 "subplot 4 3 7 '':box:error x0 y0 ex ey 'x@'\n"
1155 "subplot 4 3 8 '':box:error x0 y0 ex ey 'o@'\n"
1156 "subplot 4 3 9 '':box:error x0 y0 ex ey '#o@'; alpha 0.5\n"
1157 "subplot 4 3 10 '':box:error x0 y0 ex ey '#.@'\n"
1158 "subplot 4 3 11 '':box:error x0 y0 ex ey; alpha 0.5";
smgl_error2(mglGraph * gr)1159 void smgl_error2(mglGraph *gr)
1160 {
1161 	mglData x0(10), y0(10), ex(10), ey(10);
1162 	for(int i=0;i<10;i++)
1163 	{	x0.a[i] = mgl_rnd();	y0.a[i] = mgl_rnd();	ey.a[i] = ex.a[i] = 0.1;	}
1164 	gr->SetRanges(0,1,0,1);	gr->Alpha(true);
1165 	gr->SubPlot(4,3,0,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"#+@");
1166 	gr->SubPlot(4,3,1,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"#x@");
1167 	gr->SubPlot(4,3,2,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"#s@","alpha 0.5");
1168 	gr->SubPlot(4,3,3,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"s@");
1169 	gr->SubPlot(4,3,4,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"d@");
1170 	gr->SubPlot(4,3,5,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"#d@","alpha 0.5");
1171 	gr->SubPlot(4,3,6,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"+@");
1172 	gr->SubPlot(4,3,7,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"x@");
1173 	gr->SubPlot(4,3,8,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"o@");
1174 	gr->SubPlot(4,3,9,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"#o@","alpha 0.5");
1175 	gr->SubPlot(4,3,10,"");	gr->Box();	gr->Error(x0,y0,ex,ey,"#.@");
1176 	gr->SubPlot(4,3,11,"");	gr->Box();	gr->Error(x0,y0,ex,ey);
1177 }
1178 //-----------------------------------------------------------------------------
1179 const char *mmgl_error="call 'prepare1d'\nnew y 50 '0.7*sin(pi*x-pi) + 0.5*cos(3*pi*(x+1)/2) + 0.2*sin(pi*(x+1)/2)'\n"
1180 "new x0 10 'x + 0.1*rnd-0.05':new ex 10 '0.1':new ey 10 '0.2'\n"
1181 "new y0 10 '0.7*sin(pi*x-pi) + 0.5*cos(3*pi*(x+1)/2) + 0.2*sin(pi*(x+1)/2) + 0.2*rnd-0.1'\n"
1182 "subplot 2 2 0 '':title 'Error plot (default)':box:plot y:error x0 y0 ex ey 'k'\n"
1183 "subplot 2 2 1 '':title '\"!\" style; no e_x':box:plot y:error x0 y0 ey 'o!rgb'\n"
1184 "subplot 2 2 2 '':title '\"\\@\" style':alpha on:box:plot y:error x0 y0 ex ey '@'; alpha 0.5\n"
1185 "subplot 2 2 3:title '3d variant':rotate 50 60:axis\n"
1186 "for $1 0 9\n\terrbox 2*rnd-1 2*rnd-1 2*rnd-1 0.2 0.2 0.2 'bo'\nnext";
smgl_error(mglGraph * gr)1187 void smgl_error(mglGraph *gr)
1188 {
1189 	mglData y;	mgls_prepare1d(&y);
1190 	mglData x0(10), y0(10), ex0(10), ey0(10);
1191 	for(int i=0;i<10;i++)
1192 	{
1193 		double x = i/9.;
1194 		x0.a[i] = 2*x-1 + 0.1*mgl_rnd()-0.05;
1195 		y0.a[i] = 0.7*sin(2*M_PI*x)+0.5*cos(3*M_PI*x)+0.2*sin(M_PI*x)+0.2*mgl_rnd()-0.1;
1196 		ey0.a[i]=0.2;	ex0.a[i]=0.1;
1197 	}
1198 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Error plot (default)");	}
1199 	gr->Box();	gr->Plot(y.SubData(-1,0));	gr->Error(x0,y0,ex0,ey0,"ko");
1200 	if(big==3)	return;
1201 	gr->SubPlot(2,2,1,"");	gr->Title("'!' style; no e_x");
1202 	gr->Box();	gr->Plot(y.SubData(-1,0));	gr->Error(x0,y0,ey0,"o!rgb");
1203 	gr->SubPlot(2,2,2,"");	gr->Title("'\\@' style");	gr->Alpha(true);
1204 	gr->Box();	gr->Plot(y.SubData(-1,0));	gr->Error(x0,y0,ex0,ey0,"@","alpha 0.5");
1205 	gr->SubPlot(2,2,3);	gr->Title("3d variant");	gr->Rotate(50,60);
1206 	for(int i=0;i<10;i++)
1207 		gr->Error(mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1,2*mgl_rnd()-1), mglPoint(0.2,0.2,0.2),"bo");
1208 	gr->Axis();
1209 }
1210 //-----------------------------------------------------------------------------
1211 const char *mmgl_chart="new ch 7 2 'rnd+0.1':light on\n"
1212 "subplot 2 2 0:title 'Chart plot (default)':rotate 50 60:box:chart ch\n"
1213 "subplot 2 2 1:title '\"\\#\" style':rotate 50 60:box:chart ch '#'\n"
1214 "subplot 2 2 2:title 'Pie chart; \" \" color':rotate 50 60:\n"
1215 "axis '(y+1)/2*cos(pi*x)' '(y+1)/2*sin(pi*x)' '':box:chart ch 'bgr cmy#'\n"
1216 "subplot 2 2 3:title 'Ring chart; \" \" color':rotate 50 60:\n"
1217 "axis '(y+2)/3*cos(pi*x)' '(y+2)/3*sin(pi*x)' '':box:chart ch 'bgr cmy#'";
smgl_chart(mglGraph * gr)1218 void smgl_chart(mglGraph *gr)
1219 {
1220 	mglData ch(7,2);	for(int i=0;i<7*2;i++)	ch.a[i]=mgl_rnd()+0.1;
1221 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Chart plot (default)");	}
1222 	gr->Light(true);	gr->Rotate(50,60);	gr->Box();	gr->Chart(ch);
1223 	if(big==3)	return;
1224 	gr->SubPlot(2,2,1);	gr->Title("'\\#' style");
1225 	gr->Rotate(50,60);	gr->Box();	gr->Chart(ch,"#");
1226 	gr->SubPlot(2,2,2);	gr->Title("Pie chart; ' ' color");
1227 	gr->SetFunc("(y+1)/2*cos(pi*x)","(y+1)/2*sin(pi*x)","");
1228 	gr->Rotate(50,60);	gr->Box();	gr->Chart(ch,"bgr cmy#");
1229 	gr->SubPlot(2,2,3);	gr->Title("Ring chart; ' ' color");
1230 	gr->SetFunc("(y+2)/3*cos(pi*x)","(y+2)/3*sin(pi*x)","");
1231 	gr->Rotate(50,60);	gr->Box();	gr->Chart(ch,"bgr cmy#");
1232 }
1233 //-----------------------------------------------------------------------------
1234 const char *mmgl_mark="call 'prepare1d'\nsubplot 1 1 0 '':title 'Mark plot (default)':box:mark y y1 's'";
smgl_mark(mglGraph * gr)1235 void smgl_mark(mglGraph *gr)
1236 {
1237 	mglData y,y1;	mgls_prepare1d(&y,&y1);
1238 	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("Mark plot (default)");	}
1239 	gr->Box();	gr->Mark(y,y1,"s");
1240 }
1241 //-----------------------------------------------------------------------------
1242 const char *mmgl_radar="new yr 10 3 '0.4*sin(pi*(x+1.5+y/2)+0.1*rnd)'\n"
1243 "subplot 1 1 0 '':title 'Radar plot (with grid, \"\\#\")':radar yr '#'";
smgl_radar(mglGraph * gr)1244 void smgl_radar(mglGraph *gr)
1245 {
1246 	mglData yr(10,3);	yr.Modify("0.4*sin(pi*(2*x+y))+0.1*rnd");
1247 	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("Radar plot (with grid, '\\#')");	}
1248 	gr->Radar(yr,"#");
1249 }
1250 //-----------------------------------------------------------------------------
1251 const char *mmgl_candle="new y 30 'sin(pi*x/2)^2'\n"
1252 "subplot 1 1 0 '':title 'Candle plot (default)'\nyrange 0 1:box\ncandle y y/2 (y+1)/2";
smgl_candle(mglGraph * gr)1253 void smgl_candle(mglGraph *gr)
1254 {
1255 	mglData y(30);	gr->Fill(y,"sin(pi*x/2)^2");
1256 	mglData y1(30);	gr->Fill(y1,"v/2",y);
1257 	mglData y2(30);	gr->Fill(y2,"(1+v)/2",y);
1258 	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("Candle plot (default)");	}
1259 	gr->SetRange('y',0,1);	gr->Box();	gr->Candle(y,y1,y2);
1260 }
1261 //-----------------------------------------------------------------------------
1262 const char *mmgl_textmark="call 'prepare1d'\nsubplot 1 1 0 '':title 'TextMark plot (default)':box:textmark y y1 '\\gamma' 'r'";
smgl_textmark(mglGraph * gr)1263 void smgl_textmark(mglGraph *gr)
1264 {
1265 	mglData y,y1;	mgls_prepare1d(&y,&y1);
1266 	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("TextMark plot (default)");	}
1267 	gr->Box();	gr->TextMark(y,y1,"\\gamma","r");
1268 }
1269 //-----------------------------------------------------------------------------
1270 const char *mmgl_tube="call 'prepare1d'\nlight on\n"
1271 "new yc 50 'sin(pi*x)':new xc 50 'cos(pi*x)':new z 50 'x':divto y1 20\n"
1272 "subplot 2 2 0 '':title 'Tube plot (default)':box:tube y 0.05\n"
1273 "subplot 2 2 1 '':title 'variable radius':box:tube y y1\n"
1274 "subplot 2 2 2 '':title '\"\\#\" style':box:tube y 0.05 '#'\n"
1275 "subplot 2 2 3:title '3d variant':rotate 50 60:box:tube xc yc z y2 'r'";
smgl_tube(mglGraph * gr)1276 void smgl_tube(mglGraph *gr)
1277 {
1278 	mglData y,y1,y2;	mgls_prepare1d(&y,&y1,&y2);	y1/=20;
1279 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Tube plot (default)");	}
1280 	gr->Light(true);	gr->Box();	gr->Tube(y,0.05);
1281 	if(big==3)	return;
1282 	gr->SubPlot(2,2,1,"");	gr->Title("variable radius");	gr->Box();	gr->Tube(y,y1);
1283 	gr->SubPlot(2,2,2,"");	gr->Title("'\\#' style");	gr->Box();	gr->Tube(y,0.05,"#");
1284 	mglData yc(50), xc(50), z(50);	z.Modify("2*x-1");
1285 	yc.Modify("sin(pi*(2*x-1))");	xc.Modify("cos(pi*2*x-pi)");
1286 	gr->SubPlot(2,2,3);	gr->Title("3d variant");	gr->Rotate(50,60);	gr->Box();	gr->Tube(xc,yc,z,y2,"r");
1287 }
1288 //-----------------------------------------------------------------------------
1289 const char *mmgl_tape="call 'prepare1d'\nnew yc 50 'sin(pi*x)':new xc 50 'cos(pi*x)':new z 50 'x'\n"
1290 "subplot 2 2 0 '':title 'Tape plot (default)':box:tape y:plot y 'k'\n"
1291 "subplot 2 2 1:title '3d variant, 2 colors':rotate 50 60:light on\n"
1292 "box:plot xc yc z 'k':tape xc yc z 'rg'\n"
1293 "subplot 2 2 2:title '3d variant, x only':rotate 50 60\n"
1294 "box:plot xc yc z 'k':tape xc yc z 'xr':tape xc yc z 'xr#'\n"
1295 "subplot 2 2 3:title '3d variant, z only':rotate 50 60\n"
1296 "box:plot xc yc z 'k':tape xc yc z 'zg':tape xc yc z 'zg#'";
smgl_tape(mglGraph * gr)1297 void smgl_tape(mglGraph *gr)
1298 {
1299 	mglData y;	mgls_prepare1d(&y);
1300 	mglData xc(50), yc(50), z(50);
1301 	yc.Modify("sin(pi*(2*x-1))");
1302 	xc.Modify("cos(pi*2*x-pi)");	z.Fill(-1,1);
1303 	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Tape plot (default)");	}
1304 	gr->Box();	gr->Tape(y);	gr->Plot(y,"k");
1305 	if(big==3)	return;
1306 	gr->SubPlot(2,2,1);	gr->Title("3d variant, 2 colors");	gr->Rotate(50,60);	gr->Light(true);
1307 	gr->Box();	gr->Plot(xc,yc,z,"k");	gr->Tape(xc,yc,z,"rg");
1308 	gr->SubPlot(2,2,2);	gr->Title("3d variant, x only");	gr->Rotate(50,60);
1309 	gr->Box();	gr->Plot(xc,yc,z,"k");	gr->Tape(xc,yc,z,"xr");	gr->Tape(xc,yc,z,"xr#");
1310 	gr->SubPlot(2,2,3);	gr->Title("3d variant, z only");	gr->Rotate(50,60);
1311 	gr->Box();	gr->Plot(xc,yc,z,"k");	gr->Tape(xc,yc,z,"zg");	gr->Tape(xc,yc,z,"zg#");
1312 }
1313 //-----------------------------------------------------------------------------
1314 const char *mmgl_fog="call 'prepare2d'\ntitle 'Fog sample':rotate 50 60:light on:fog 1\nbox:surf a:cont a 'y'";
smgl_fog(mglGraph * gr)1315 void smgl_fog(mglGraph *gr)
1316 {
1317 	mglData a;	mgls_prepare2d(&a);
1318 	if(big!=3)	gr->Title("Fog sample");
1319 	gr->Light(true);	gr->Rotate(50,60);	gr->Fog(1);	gr->Box();
1320 	gr->Surf(a);	gr->Cont(a,"y");
1321 }
1322 //-----------------------------------------------------------------------------
1323 const char *mmgl_map="new a 50 40 'x':new b 50 40 'y':zrange -2 2:text 0 0 '\\to'\n"
1324 "subplot 2 1 0:text 0 1.1 '\\{x, y\\}' '' -2:box:map a b 'brgk'\n"
1325 "subplot 2 1 1:text 0 1.1 '\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}' '' -2\n"
1326 "box:fill a '(x^3+y^3)/2':fill b '(x-y)/2':map a b 'brgk'";
smgl_map(mglGraph * gr)1327 void smgl_map(mglGraph *gr)	// example of mapping
1328 {
1329 	mglData a(50, 40), b(50, 40);
1330 	gr->Puts(mglPoint(0, 0), "\\to", ":C", -1.4);
1331 	gr->SetRanges(-1,1,-1,1,-2,2);
1332 
1333 	gr->SubPlot(2, 1, 0);
1334 	gr->Fill(a,"x");	gr->Fill(b,"y");
1335 	gr->Puts(mglPoint(0, 1.1), "\\{x, y\\}", ":C", -2);		gr->Box();
1336 	gr->Map(a, b, "brgk");
1337 
1338 	gr->SubPlot(2, 1, 1);
1339 	gr->Fill(a,"(x^3+y^3)/2");	gr->Fill(b,"(x-y)/2");
1340 	gr->Puts(mglPoint(0, 1.1), "\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}", ":C", -2);
1341 	gr->Box();
1342 	gr->Map(a, b, "brgk");
1343 }
1344 //-----------------------------------------------------------------------------
1345 const char *mmgl_stfa="new a 2000:new b 2000\nfill a 'cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+\\\n"
1346 "cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)'\n"
1347 "subplot 1 2 0 '<_':title 'Initial signal':plot a:axis:xlabel '\\i t'\n"
1348 "subplot 1 2 1 '<_':title 'STFA plot':stfa a b 64:axis:ylabel '\\omega' 0:xlabel '\\i t'";
smgl_stfa(mglGraph * gr)1349 void smgl_stfa(mglGraph *gr)	// STFA sample
1350 {
1351 	mglData a(2000), b(2000);
1352 	gr->Fill(a,"cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+\
1353 	cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)");
1354 	gr->SubPlot(1, 2, 0,"<_");	gr->Title("Initial signal");
1355 	gr->Plot(a);
1356 	gr->Axis();
1357 	gr->Label('x', "\\i t");
1358 
1359 	gr->SubPlot(1, 2, 1,"<_");	gr->Title("STFA plot");
1360 	gr->STFA(a, b, 64);
1361 	gr->Axis();
1362 	gr->Label('x', "\\i t");
1363 	gr->Label('y', "\\omega", 0);
1364 }
1365 //-----------------------------------------------------------------------------
1366 const char *mmgl_qo2d="define $1 'p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)'\n"
1367 "subplot 1 1 0 '<_':title 'Beam and ray tracing'\n"
1368 "ray r $1 -0.7 -1 0 0 0.5 0 0.02 2:plot r(0) r(1) 'k'\naxis:xlabel '\\i x':ylabel '\\i z'\n"
1369 "new re 128 'exp(-48*x^2)':new im 128\nnew xx 1:new yy 1\nqo2d a $1 re im r 1 30 xx yy\n"
1370 "crange 0 1:dens xx yy a 'wyrRk':fplot '-x' 'k|'\n"
1371 "text 0 0.85 'absorption: (x+y)/2 for x+y>0'\ntext 0.7 -0.05 'central ray'";
smgl_qo2d(mglGraph * gr)1372 void smgl_qo2d(mglGraph *gr)
1373 {
1374 	mglData r, xx, yy, a, im(128), re(128);
1375 	const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)";
1376 	r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2);
1377 	if(big!=3)	{gr->SubPlot(1,1,0,"<_");	gr->Title("Beam and ray tracing");}
1378 	gr->Plot(r.SubData(0), r.SubData(1), "k");
1379 	gr->Axis();	gr->Label('x', "\\i x");	gr->Label('y', "\\i y");
1380 	// now start beam tracing
1381 	gr->Fill(re,"exp(-48*x^2)");
1382 	a = mglQO2d(ham, re, im, r, xx, yy, 1, 30);
1383 	gr->SetRange('c',0, 1);
1384 	gr->Dens(xx, yy, a, "wyrRk");
1385 	gr->FPlot("-x", "k|");
1386 	gr->Puts(mglPoint(0, 0.85), "absorption: (x+y)/2 for x+y>0");
1387 	gr->Puts(mglPoint(0.7, -0.05), "central ray");
1388 }
1389 //-----------------------------------------------------------------------------
1390 const char *mmgl_pde="new re 128 'exp(-48*(x+0.7)^2)':new im 128\n"
1391 "pde a 'p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)' re im 0.01 30\ntranspose a\n"
1392 "subplot 1 1 0 '<_':title 'PDE solver'\n"
1393 "axis:xlabel '\\i x':ylabel '\\i z'\ncrange 0 1:dens a 'wyrRk'\n"
1394 "fplot '-x' 'k|'\n"
1395 "text 0 0.95 'Equation: ik_0\\partial_zu + \\Delta u + x\\cdot u + i \\frac{x+z}{2}\\cdot u = 0\\n{}absorption: (x+z)/2 for x+z>0'";
smgl_pde(mglGraph * gr)1396 void smgl_pde(mglGraph *gr)	// PDE sample
1397 {
1398 	mglData a,re(128),im(128);
1399 	gr->Fill(re,"exp(-48*(x+0.7)^2)");
1400 	a = gr->PDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30);
1401 	a.Transpose("yxz");
1402 	if(big!=3)	{gr->SubPlot(1,1,0,"<_");	gr->Title("PDE solver");	}
1403 	gr->SetRange('c',0,1);	gr->Dens(a,"wyrRk");
1404 	gr->Axis();	gr->Label('x', "\\i x");	gr->Label('y', "\\i z");
1405 	gr->FPlot("-x", "k|");
1406 	gr->Puts(mglPoint(0, 0.95), "Equation: ik_0\\partial_zu + \\Delta u + x\\cdot u + i \\frac{x+z}{2}\\cdot u = 0\nabsorption: (x+z)/2 for x+z>0");
1407 }
1408 //-----------------------------------------------------------------------------
1409 const char *mmgl_cont3="call 'prepare3d'\ntitle 'Cont3 sample':rotate 50 60:box\ncont3 c 'x':cont3 c:cont3 c 'z'";
smgl_cont3(mglGraph * gr)1410 void smgl_cont3(mglGraph *gr)
1411 {
1412 	mglData c;	mgls_prepare3d(&c);
1413 	if(big!=3)	gr->Title("Cont3 sample");
1414 	gr->Rotate(50,60);	gr->Box();
1415 	gr->Cont3(c,"x");	gr->Cont3(c);	gr->Cont3(c,"z");
1416 }
1417 //-----------------------------------------------------------------------------
1418 const char *mmgl_contf3="call 'prepare3d'\ntitle 'Cont3 sample':rotate 50 60:box:light on\n"
1419 "contf3 c 'x':contf3 c:contf3 c 'z'\ncont3 c 'xk':cont3 c 'k':cont3 c 'zk'";
smgl_contf3(mglGraph * gr)1420 void smgl_contf3(mglGraph *gr)
1421 {
1422 	mglData c;	mgls_prepare3d(&c);
1423 	if(big!=3)	gr->Title("ContF3 sample");
1424 	gr->Rotate(50,60);	gr->Light(true);	gr->Box();
1425 	gr->ContF3(c,"x");	gr->ContF3(c);		gr->ContF3(c,"z");
1426 	gr->Cont3(c,"kx");	gr->Cont3(c,"k");	gr->Cont3(c,"kz");
1427 }
1428 //-----------------------------------------------------------------------------
1429 const char *mmgl_dens3="call 'prepare3d'\ntitle 'Dens3 sample':rotate 50 60:alpha on:alphadef 0.7\n"
1430 "origin 0 0 0:box:axis '_xyz'\ndens3 c 'x':dens3 c ':y':dens3 c 'z'";
smgl_dens3(mglGraph * gr)1431 void smgl_dens3(mglGraph *gr)
1432 {
1433 	mglData c;	mgls_prepare3d(&c);
1434 	if(big!=3)	gr->Title("Dens3 sample");
1435 	gr->Rotate(50,60);	gr->Alpha(true);	gr->SetAlphaDef(0.7);
1436 	gr->SetOrigin(0,0,0);	gr->Axis("_xyz");	gr->Box();
1437 	gr->Dens3(c,"x");	gr->Dens3(c);	gr->Dens3(c,"z");
1438 }
1439 //-----------------------------------------------------------------------------
1440 const char *mmgl_dens_xyz="call 'prepare3d'\ntitle 'Dens[XYZ] sample':rotate 50 60:box\n"
1441 "densx {sum c 'x'} '' -1:densy {sum c 'y'} '' 1:densz {sum c 'z'} '' -1";
smgl_dens_xyz(mglGraph * gr)1442 void smgl_dens_xyz(mglGraph *gr)
1443 {
1444 	mglData c;	mgls_prepare3d(&c);
1445 	if(big!=3)	gr->Title("Dens[XYZ] sample");
1446 	gr->Rotate(50,60);	gr->Box();	gr->DensX(c.Sum("x"),0,-1);
1447 	gr->DensY(c.Sum("y"),0,1);		gr->DensZ(c.Sum("z"),0,-1);
1448 }
1449 //-----------------------------------------------------------------------------
1450 const char *mmgl_cont_xyz="call 'prepare3d'\ntitle 'Cont[XYZ] sample':rotate 50 60:box\n"
1451 "contx {sum c 'x'} '' -1:conty {sum c 'y'} '' 1:contz {sum c 'z'} '' -1";
smgl_cont_xyz(mglGraph * gr)1452 void smgl_cont_xyz(mglGraph *gr)
1453 {
1454 	mglData c;	mgls_prepare3d(&c);
1455 	if(big!=3)	gr->Title("Cont[XYZ] sample");
1456 	gr->Rotate(50,60);	gr->Box();	gr->ContX(c.Sum("x"),"",-1);
1457 	gr->ContY(c.Sum("y"),"",1);		gr->ContZ(c.Sum("z"),"",-1);
1458 }
1459 //-----------------------------------------------------------------------------
1460 const char *mmgl_contf_xyz="call 'prepare3d'\ntitle 'ContF[XYZ] sample':rotate 50 60:box\n"
1461 "contfx {sum c 'x'} '' -1:contfy {sum c 'y'} '' 1:contfz {sum c 'z'} '' -1";
smgl_contf_xyz(mglGraph * gr)1462 void smgl_contf_xyz(mglGraph *gr)
1463 {
1464 	mglData c;	mgls_prepare3d(&c);
1465 	if(big!=3)	gr->Title("ContF[XYZ] sample");
1466 	gr->Rotate(50,60);	gr->Box();	gr->ContFX(c.Sum("x"),"",-1);
1467 	gr->ContFY(c.Sum("y"),"",1);	gr->ContFZ(c.Sum("z"),"",-1);
1468 }
1469 //-----------------------------------------------------------------------------
1470 const char *mmgl_cloud="call 'prepare3d'\nsubplot 2 2 0:title 'Cloud plot':rotate 50 60:alpha on:box:cloud c 'wyrRk'\n"
1471 "subplot 2 2 1:title '\"i\" style':rotate 50 60:box:cloud c 'iwyrRk'\n"
1472 "subplot 2 2 2:title '\".\" style':rotate 50 60:box:cloud c '.wyrRk'\n"
1473 "subplot 2 2 3:title 'meshnum 10':rotate 50 60:box:cloud c 'wyrRk'; meshnum 10";
smgl_cloud(mglGraph * gr)1474 void smgl_cloud(mglGraph *gr)
1475 {
1476 	mglData c;	mgls_prepare3d(&c);
1477 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Cloud plot");	}
1478 	gr->Rotate(50,60);	gr->Alpha(true);
1479 	gr->Box();	gr->Cloud(c,"wyrRk");
1480 	if(big==3)	return;
1481 	gr->SubPlot(2,2,1);	gr->Title("'i' style");
1482 	gr->Rotate(50,60);	gr->Box();	gr->Cloud(c,"iwyrRk");
1483 	gr->SubPlot(2,2,2);	gr->Title("'.' style");
1484 	gr->Rotate(50,60);	gr->Box();	gr->Cloud(c,".wyrRk");
1485 	gr->SubPlot(2,2,3);	gr->Title("meshnum 10");
1486 	gr->Rotate(50,60);	gr->Box();	gr->Cloud(c,"wyrRk","meshnum 10");
1487 }
1488 //-----------------------------------------------------------------------------
1489 const char *mmgl_cont="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\nsubplot 2 2 0:title 'Cont plot (default)':rotate 50 60:box:cont a\n"
1490 "subplot 2 2 1:title 'manual levels':rotate 50 60:box:cont v a\n"
1491 "subplot 2 2 2:title '\"\\_\" and \".\" styles':rotate 50 60:box:cont a '_':cont a '_.2k'\n"
1492 "subplot 2 2 3 '':title '\"t\" style':box:cont a 't'";
smgl_cont(mglGraph * gr)1493 void smgl_cont(mglGraph *gr)
1494 {
1495 	mglData a,v(5);	mgls_prepare2d(&a);	v.a[0]=-0.5;	v.a[1]=-0.15;	v.a[2]=0;	v.a[3]=0.15;	v.a[4]=0.5;
1496 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Cont plot (default)");	}
1497 	gr->Rotate(50,60);	gr->Box();	gr->Cont(a);
1498 	if(big==3)	return;
1499 	gr->SubPlot(2,2,1);	gr->Title("manual levels");
1500 	gr->Rotate(50,60);	gr->Box();	gr->Cont(v,a);
1501 	gr->SubPlot(2,2,2);	gr->Title("'\\_' and '.' styles");
1502 	gr->Rotate(50,60);	gr->Box();	gr->Cont(a,"_");	gr->Cont(a,"_.2k");
1503 	gr->SubPlot(2,2,3,"");	gr->Title("'t' style");
1504 	gr->Box();	gr->Cont(a,"t");
1505 }
1506 //-----------------------------------------------------------------------------
1507 const char *mmgl_contf="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\n"
1508 "new a1 30 40 3 '0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)'\n"
1509 "subplot 2 2 0:title 'ContF plot (default)':rotate 50 60:box:contf a\n"
1510 "subplot 2 2 1:title 'manual levels':rotate 50 60:box:contf v a\n"
1511 "subplot 2 2 2:title '\"\\_\" style':rotate 50 60:box:contf a '_'\n"
1512 "subplot 2 2 3:title 'several slices':rotate 50 60:box:contf a1";
smgl_contf(mglGraph * gr)1513 void smgl_contf(mglGraph *gr)
1514 {
1515 	mglData a,v(5),a1(30,40,3);	mgls_prepare2d(&a);	v.a[0]=-0.5;
1516 	v.a[1]=-0.15;	v.a[2]=0;	v.a[3]=0.15;	v.a[4]=0.5;
1517 	gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)");
1518 
1519 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("ContF plot (default)");	}
1520 	gr->Rotate(50,60);	gr->Box();	gr->ContF(a);
1521 	if(big==3)	return;
1522 	gr->SubPlot(2,2,1);	gr->Title("manual levels");
1523 	gr->Rotate(50,60);	gr->Box();	gr->ContF(v,a);
1524 	gr->SubPlot(2,2,2);	gr->Title("'\\_' style");
1525 	gr->Rotate(50,60);	gr->Box();	gr->ContF(a,"_");
1526 	gr->SubPlot(2,2,3);	gr->Title("several slices");
1527 	gr->Rotate(50,60);	gr->Box();	gr->ContF(a1);
1528 }
1529 //-----------------------------------------------------------------------------
1530 const char *mmgl_contd="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\n"
1531 "new a1 30 40 3 '0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)'\n"
1532 "subplot 2 2 0:title 'ContD plot (default)':rotate 50 60:box:contd a\n"
1533 "subplot 2 2 1:title 'manual levels':rotate 50 60:box:contd v a\n"
1534 "subplot 2 2 2:title '\"\\_\" style':rotate 50 60:box:contd a '_'\n"
1535 "subplot 2 2 3:title 'several slices':rotate 50 60:box:contd a1";
smgl_contd(mglGraph * gr)1536 void smgl_contd(mglGraph *gr)
1537 {
1538 	mglData a,v(5),a1(30,40,3);	mgls_prepare2d(&a);	v.a[0]=-0.5;
1539 	v.a[1]=-0.15;	v.a[2]=0;	v.a[3]=0.15;	v.a[4]=0.5;
1540 	gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)");
1541 
1542 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("ContD plot (default)");	}
1543 	gr->Rotate(50,60);	gr->Box();	gr->ContD(a);
1544 	if(big==3)	return;
1545 	gr->SubPlot(2,2,1);	gr->Title("manual levels");
1546 	gr->Rotate(50,60);	gr->Box();	gr->ContD(v,a);
1547 	gr->SubPlot(2,2,2);	gr->Title("'\\_' style");
1548 	gr->Rotate(50,60);	gr->Box();	gr->ContD(a,"_");
1549 	gr->SubPlot(2,2,3);	gr->Title("several slices");
1550 	gr->Rotate(50,60);	gr->Box();	gr->ContD(a1);
1551 }
1552 //-----------------------------------------------------------------------------
1553 const char *mmgl_contv="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\n"
1554 "subplot 2 2 0:title 'ContV plot (default)':rotate 50 60:box:contv a\n"
1555 "subplot 2 2 1:title 'manual levels':rotate 50 60:box:contv v a\n"
1556 "subplot 2 2 2:title '\"\\_\" style':rotate 50 60:box:contv a '_'\n"
1557 "subplot 2 2 3:title 'ContV and ContF':rotate 50 60:light on:box\ncontv a:contf a:cont a 'k'";
smgl_contv(mglGraph * gr)1558 void smgl_contv(mglGraph *gr)
1559 {
1560 	mglData a,v(5);	mgls_prepare2d(&a);	v.a[0]=-0.5;
1561 	v.a[1]=-0.15;	v.a[2]=0;	v.a[3]=0.15;	v.a[4]=0.5;
1562 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("ContV plot (default)");	}
1563 	gr->Rotate(50,60);	gr->Box();	gr->ContV(a);
1564 	if(big==3)	return;
1565 	gr->SubPlot(2,2,1);	gr->Title("manual levels");
1566 	gr->Rotate(50,60);	gr->Box();	gr->ContV(v,a);
1567 	gr->SubPlot(2,2,2);	gr->Title("'\\_' style");
1568 	gr->Rotate(50,60);	gr->Box();	gr->ContV(a,"_");
1569 	gr->SubPlot(2,2,3);	gr->Title("ContV and ContF");
1570 	gr->Rotate(50,60);	gr->Box();	gr->Light(true);
1571 	gr->ContV(a);	gr->ContF(a);	gr->Cont(a,"k");
1572 }
1573 //-----------------------------------------------------------------------------
1574 const char *mmgl_torus="call 'prepare1d'\nsubplot 2 2 0:title 'Torus plot (default)':light on:rotate 50 60:box:torus y1 y2\n"
1575 "subplot 2 2 1:title '\"x\" style':light on:rotate 50 60:box:torus y1 y2 'x'\n"
1576 "subplot 2 2 2:title '\"z\" style':light on:rotate 50 60:box:torus y1 y2 'z'\n"
1577 "subplot 2 2 3:title '\"\\#\" style':light on:rotate 50 60:box:torus y1 y2 '#'";
smgl_torus(mglGraph * gr)1578 void smgl_torus(mglGraph *gr)
1579 {
1580 	mglData y1,y2;	mgls_prepare1d(0,&y1,&y2);
1581 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Torus plot (default)");	}
1582 	gr->Light(true);	gr->Rotate(50,60);	gr->Box();	gr->Torus(y1,y2);
1583 	if(big==3)	return;
1584 	gr->SubPlot(2,2,1);	gr->Title("'x' style");	gr->Rotate(50,60);	gr->Box();	gr->Torus(y1,y2,"x");
1585 	gr->SubPlot(2,2,2);	gr->Title("'z' style");	gr->Rotate(50,60);	gr->Box();	gr->Torus(y1,y2,"z");
1586 	gr->SubPlot(2,2,3);	gr->Title("'\\#' style");	gr->Rotate(50,60);	gr->Box();	gr->Torus(y1,y2,"#");
1587 }
1588 //-----------------------------------------------------------------------------
1589 const char *mmgl_axial="call 'prepare2d'\nsubplot 2 2 0:title 'Axial plot (default)':light on:alpha on:rotate 50 60:box:axial a\n"
1590 "subplot 2 2 1:title '\"x\" style;\".\" style':light on:rotate 50 60:box:axial a 'x.'\n"
1591 "subplot 2 2 2:title '\"z\" style':light on:rotate 50 60:box:axial a 'z'\n"
1592 "subplot 2 2 3:title '\"\\#\" style':light on:rotate 50 60:box:axial a '#'";
smgl_axial(mglGraph * gr)1593 void smgl_axial(mglGraph *gr)
1594 {
1595 	mglData a;	mgls_prepare2d(&a);
1596 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Axial plot (default)");	}
1597 	gr->Light(true);	gr->Alpha(true);	gr->Rotate(50,60);	gr->Box();	gr->Axial(a);
1598 	if(big==3)	return;
1599 	gr->SubPlot(2,2,1);	gr->Title("'x' style; '.'style");	gr->Rotate(50,60);	gr->Box();	gr->Axial(a,"x.");
1600 	gr->SubPlot(2,2,2);	gr->Title("'z' style");	gr->Rotate(50,60);	gr->Box();	gr->Axial(a,"z");
1601 	gr->SubPlot(2,2,3);	gr->Title("'\\#' style");	gr->Rotate(50,60);	gr->Box();	gr->Axial(a,"#");
1602 }
1603 //-----------------------------------------------------------------------------
1604 const char *mmgl_several_light="call 'prepare2d'\ntitle 'Several light sources':rotate 50 60:light on\n"
1605 "light 1 0 1 0 'c':light 2 1 0 0 'y':light 3 0 -1 0 'm'\nbox:surf a 'h'";
smgl_several_light(mglGraph * gr)1606 void smgl_several_light(mglGraph *gr)	// several light sources
1607 {
1608 	mglData a;	mgls_prepare2d(&a);
1609 	if(big!=3)	gr->Title("Several light sources");
1610 	gr->Rotate(50,60);	gr->Light(true);	gr->AddLight(1,mglPoint(0,1,0),'c');
1611 	gr->AddLight(2,mglPoint(1,0,0),'y');	gr->AddLight(3,mglPoint(0,-1,0),'m');
1612 	gr->Box();	gr->Surf(a,"h");
1613 }
1614 //-----------------------------------------------------------------------------
1615 const char *mmgl_light="light on:attachlight on\ncall 'prepare2d'\n"
1616 "subplot 2 2 0:title 'Default':rotate 50 60:box:surf a\nline -1 -0.7 1.7 -1 -0.7 0.7 'BA'\n\n"
1617 "subplot 2 2 1:title 'Local':rotate 50 60\nlight 0 1 0 1 -2 -1 -1\nline 1 0 1 -1 -1 0 'BAO':box:surf a\n\n"
1618 "subplot 2 2 2:title 'no diffuse':rotate 50 60\ndiffuse 0\nline 1 0 1 -1 -1 0 'BAO':box:surf a\n\n"
1619 "subplot 2 2 3:title 'diffusive only':rotate 50 60\ndiffuse 0.5:light 0 1 0 1 -2 -1 -1 'w' 0\n"
1620 "line 1 0 1 -1 -1 0 'BAO':box:surf a";
smgl_light(mglGraph * gr)1621 void smgl_light(mglGraph *gr)	// local light sources
1622 {
1623 	mglData a;	mgls_prepare2d(&a);
1624 	gr->Light(true);	gr->AttachLight(true);
1625 	if(big==3)
1626 	{	gr->Rotate(50,60);	gr->Box();	gr->Surf(a);	return;	}
1627 	gr->SubPlot(2,2,0);	gr->Title("Default");	gr->Rotate(50,60);
1628 	gr->Line(mglPoint(-1,-0.7,1.7),mglPoint(-1,-0.7,0.7),"BA");	gr->Box();	gr->Surf(a);
1629 	gr->SubPlot(2,2,1);	gr->Title("Local");	gr->Rotate(50,60);
1630 	gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1));
1631 	gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO");	gr->Box();	gr->Surf(a);
1632 	gr->SubPlot(2,2,2);	gr->Title("no diffuse");	gr->Rotate(50,60);
1633 	gr->SetDiffuse(0);
1634 	gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO");	gr->Box();	gr->Surf(a);
1635 	gr->SubPlot(2,2,3);	gr->Title("diffusive only");	gr->Rotate(50,60);
1636 	gr->SetDiffuse(0.5);
1637 	gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1),'w',0);
1638 	gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO");	gr->Box();	gr->Surf(a);
1639 }
1640 //-----------------------------------------------------------------------------
1641 const char *mmgl_surf3="call 'prepare3d'\nlight on:alpha on\n"
1642 "subplot 2 2 0:title 'Surf3 plot (default)'\nrotate 50 60:box:surf3 c\n"
1643 "subplot 2 2 1:title '\"\\#\" style'\nrotate 50 60:box:surf3 c '#'\n"
1644 "subplot 2 2 2:title '\".\" style'\nrotate 50 60:box:surf3 c '.'";
smgl_surf3(mglGraph * gr)1645 void smgl_surf3(mglGraph *gr)
1646 {
1647 	mglData c;	mgls_prepare3d(&c);
1648 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Surf3 plot (default)");	}
1649 	gr->Rotate(50,60);	gr->Light(true);	gr->Alpha(true);
1650 	gr->Box();	gr->Surf3(c);
1651 	if(big==3)	return;
1652 	gr->SubPlot(2,2,1);	gr->Title("'\\#' style");
1653 	gr->Rotate(50,60);	gr->Box();	gr->Surf3(c,"#");
1654 	gr->SubPlot(2,2,2);	gr->Title("'.' style");
1655 	gr->Rotate(50,60);	gr->Box();	gr->Surf3(c,".");
1656 }
1657 //-----------------------------------------------------------------------------
1658 const char *mmgl_surf3a="call 'prepare3d'\ntitle 'Surf3A plot':rotate 50 60:light on:alpha on:box:surf3a c d";
smgl_surf3a(mglGraph * gr)1659 void smgl_surf3a(mglGraph *gr)
1660 {
1661 	mglData c,d;	mgls_prepare3d(&c,&d);
1662 	if(big!=3)	gr->Title("Surf3A plot");
1663 	gr->Rotate(50,60);	gr->Light(true);	gr->Alpha(true);
1664 	gr->Box();	gr->Surf3A(c,d);
1665 }
1666 //-----------------------------------------------------------------------------
1667 const char *mmgl_surf3c="call 'prepare3d'\ntitle 'Surf3C plot':rotate 50 60:light on:alpha on:box:surf3c c d";
smgl_surf3c(mglGraph * gr)1668 void smgl_surf3c(mglGraph *gr)
1669 {
1670 	mglData c,d;	mgls_prepare3d(&c,&d);
1671 	if(big!=3)	gr->Title("Surf3C plot");
1672 	gr->Rotate(50,60);	gr->Light(true);	gr->Alpha(true);
1673 	gr->Box();	gr->Surf3C(c,d);
1674 }
1675 //-----------------------------------------------------------------------------
1676 const char *mmgl_surf3ca="call 'prepare3d'\ntitle 'Surf3CA plot':rotate 50 60:light on:alpha on:box:surf3ca c d c";
smgl_surf3ca(mglGraph * gr)1677 void smgl_surf3ca(mglGraph *gr)
1678 {
1679 	mglData c,d;	mgls_prepare3d(&c,&d);
1680 	if(big!=3)	gr->Title("Surf3CA plot");
1681 	gr->Rotate(50,60);	gr->Light(true);	gr->Alpha(true);
1682 	gr->Box();	gr->Surf3CA(c,d,c);
1683 }
1684 //-----------------------------------------------------------------------------
1685 const char *mmgl_dcont="call 'prepare3d'\ntitle 'DCont plot':rotate 50 60:light on:alpha on:box:surf3 c 0 'r':surf3 d 0 'b'\ndcont 0 c d '2k'";
smgl_dcont(mglGraph * gr)1686 void smgl_dcont(mglGraph *gr)
1687 {
1688 	mglData c,d,v;	mgls_prepare3d(&c,&d);
1689 	if(big!=3)	gr->Title("DCont plot");
1690 	gr->Rotate(50,60);	gr->Light(true);	gr->Alpha(true);
1691 	gr->Box();	gr->Surf3(0,c,"r");	gr->Surf3(0,d,"b");
1692 	gr->DCont(v,c,d,"2k");
1693 }
1694 //-----------------------------------------------------------------------------
1695 const char *mmgl_daisy="title 'Advanced formulas'\nnew b 256 256 'dsum(fn1(_i*pi/5),10)\\exp(-64*(x*cos(_1)-y*sin(_1))^2-16*(0.5+y*cos(_1)+x*sin(_1))^2)'\ncrange b:dens b 'BbwrR'";
smgl_daisy(mglGraph * gr)1696 void smgl_daisy(mglGraph *gr)
1697 {
1698 	if(big!=3)	gr->Title("Advanced formulas");
1699 	mglData b(256,256);
1700 	gr->Fill(b,"dsum(fn1(_i*pi/5),10)\\exp(-64*(x*cos(_1)-y*sin(_1))^2-16*(0.5+y*cos(_1)+x*sin(_1))^2)");
1701 	gr->SetRange('c',b);	gr->Dens(b,"BbwrR");
1702 }
1703 //-----------------------------------------------------------------------------
1704 const char *mmgl_keep="yrange 0 pi\nnew !a 100 300 'exp(-6*x^2+10i*(x+y^2))'"
1705 "subplot 2 1 0 '':box\ndens real(a) 'BbwrR'\ntext 1.1 0.5 '\to' 'a'"
1706 "keep a 'y' 50\nsubplot 2 1 1 '':box\ndens real(a) 'BbwrR'";
smgl_keep(mglGraph * gr)1707 void smgl_keep(mglGraph *gr)
1708 {
1709 	gr->SetRange('y',0,M_PI);
1710 	mglDataC a(100,300);	gr->Fill(a,"exp(-6*x^2+10i*(x+y^2))");
1711 	gr->SubPlot(2,1,0,"");	gr->Box();
1712 	gr->Dens(a.Real(),"BbwrR");
1713 	gr->Puts(1.1,0.5,"\\to","a");
1714 	a.Keep("y",50);
1715 	gr->SubPlot(2,1,1,"");	gr->Box();
1716 	gr->Dens(a.Real(),"BbwrR");
1717 }
1718 //-----------------------------------------------------------------------------
1719 const char *mmgl_cut="call 'prepare2d'\ncall 'prepare3d'\nsubplot 2 2 0:title 'Cut on (default)':rotate 50 60:light on:box:surf a; zrange -1 0.5\n"
1720 "subplot 2 2 1:title 'Cut off':rotate 50 60:box:surf a; zrange -1 0.5; cut off\n"
1721 "subplot 2 2 2:title 'Cut in box':rotate 50 60:box:alpha on\ncut 0 -1 -1 1 0 1.1:surf3 c\ncut 0 0 0 0 0 0\t# restore back\n"
1722 "subplot 2 2 3:title 'Cut by formula':rotate 50 60:box\ncut '(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)':surf3 c";
smgl_cut(mglGraph * gr)1723 void smgl_cut(mglGraph *gr)	// cutting
1724 {
1725 	mglData a,c,v(1);	mgls_prepare2d(&a);	mgls_prepare3d(&c);	v.a[0]=0.5;
1726 	gr->SubPlot(2,2,0);	gr->Title("Cut on (default)");	gr->Rotate(50,60);	gr->Light(true);
1727 	gr->Box();	gr->Surf(a,"","zrange -1 0.5");
1728 	gr->SubPlot(2,2,1);	gr->Title("Cut off");		gr->Rotate(50,60);
1729 	gr->Box();	gr->Surf(a,"","zrange -1 0.5; cut off");
1730 	gr->SubPlot(2,2,2);	gr->Title("Cut in box");	gr->Rotate(50,60);
1731 	gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1));
1732 	gr->Alpha(true);	gr->Box();	gr->Surf3(c);
1733 	gr->SetCutBox(mglPoint(0), mglPoint(0));	// switch it off
1734 	gr->SubPlot(2,2,3);	gr->Title("Cut by formula");	gr->Rotate(50,60);
1735 	gr->CutOff("(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)");
1736 	gr->Box();	gr->Surf3(c);	gr->CutOff("");	// switch it off
1737 }
1738 //-----------------------------------------------------------------------------
1739 const char *mmgl_traj="call 'prepare1d'\nsubplot 1 1 0 '':title 'Traj plot':box:plot x1 y:traj x1 y y1 y2";
smgl_traj(mglGraph * gr)1740 void smgl_traj(mglGraph *gr)
1741 {
1742 	mglData x,y,y1,y2;	mgls_prepare1d(&y,&y1,&y2,&x);
1743 	if(big!=3)	{gr->SubPlot(1,1,0,"");	gr->Title("Traj plot");}
1744 	gr->Box();	gr->Plot(x,y);	gr->Traj(x,y,y1,y2);
1745 }
1746 //-----------------------------------------------------------------------------
1747 const char *mmgl_lines="subplot 1 1 0 '':title 'Lines plot'\n"
1748 "new x1 11 '0.3*cos(pi*i/5)'\nnew y1 11 '0.3*sin(pi*i/5)'\nnew x2 11 '0.7*cos(pi*i/5)'\nnew y2 11 '0.7*sin(pi*i/5)'\nplot x1 y1\nlines x1 y1 x2 y2 '_A'";
smgl_lines(mglGraph * gr)1749 void smgl_lines(mglGraph *gr)
1750 {
1751 	mglData x1(11),y1(11),x2(11),y2(11);
1752 	for(long i=0;i<11;i++)
1753 	{
1754 		x1.a[i] = 0.3*cos(M_PI*i/5);
1755 		y1.a[i] = 0.3*sin(M_PI*i/5);
1756 		x2.a[i] = 0.7*cos(M_PI*i/5);
1757 		y2.a[i] = 0.7*sin(M_PI*i/5);
1758 	}
1759 	if(big!=3)	{gr->SubPlot(1,1,0,"");	gr->Title("Lines plot");}
1760 	gr->Plot(x1,y1);
1761 	gr->Lines(x1,y1,x2,y2,"_A");
1762 }
1763 //-----------------------------------------------------------------------------
1764 const char *mmgl_mesh="call 'prepare2d'\ntitle 'Mesh plot':rotate 50 60:box:mesh a";
smgl_mesh(mglGraph * gr)1765 void smgl_mesh(mglGraph *gr)
1766 {
1767 	mglData a;	mgls_prepare2d(&a);
1768 	if(big!=3)	gr->Title("Mesh plot");
1769 	gr->Rotate(50,60);	gr->Box();	gr->Mesh(a);
1770 }
1771 //-----------------------------------------------------------------------------
1772 const char *mmgl_fall="call 'prepare2d'\ntitle 'Fall plot':rotate 50 60:box:fall a";
smgl_fall(mglGraph * gr)1773 void smgl_fall(mglGraph *gr)
1774 {
1775 	mglData a;	mgls_prepare2d(&a);
1776 	if(big!=3)	gr->Title("Fall plot");
1777 	gr->Rotate(50,60);	gr->Box();	gr->Fall(a);
1778 }
1779 //-----------------------------------------------------------------------------
1780 const char *mmgl_surf="call 'prepare2d'\nsubplot 2 2 0:title 'Surf plot (default)':rotate 50 60:light on:box:surf a\n"
1781 "subplot 2 2 1:title '\"\\#\" style; meshnum 10':rotate 50 60:box:surf a '#'; meshnum 10\n"
1782 "subplot 2 2 2:title '\".\" style':rotate 50 60:box:surf a '.'\n"
1783 "new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'\nnew y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'\nnew z 50 40 '0.8*cos(pi*(y+1)/2)'\n"
1784 "subplot 2 2 3:title 'parametric form':rotate 50 60:box:surf x y z 'BbwrR'";
smgl_surf(mglGraph * gr)1785 void smgl_surf(mglGraph *gr)
1786 {
1787 	mglData a;	mgls_prepare2d(&a);
1788 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Surf plot (default)");	}
1789 	gr->Light(true);	gr->Rotate(50,60);	gr->Box();	gr->Surf(a);
1790 	if(big==3)	return;
1791 	gr->SubPlot(2,2,1);	gr->Title("'\\#' style; meshnum 10");
1792 	gr->Rotate(50,60);	gr->Box();	gr->Surf(a,"#","meshnum 10");
1793 	gr->SubPlot(2,2,2);	gr->Title("'.' style");
1794 	gr->Rotate(50,60);	gr->Box();	gr->Surf(a,".");
1795 	gr->SubPlot(2,2,3);	gr->Title("parametric form");
1796 	mglData x(50,40),y(50,40),z(50,40);
1797 	gr->Fill(x,"0.8*sin(pi*x)*sin(pi*(y+1)/2)");
1798 	gr->Fill(y,"0.8*cos(pi*x)*sin(pi*(y+1)/2)");
1799 	gr->Fill(z,"0.8*cos(pi*(y+1)/2)");
1800 	gr->Rotate(50,60);	gr->Box();	gr->Surf(x,y,z,"BbwrR");
1801 }
1802 //-----------------------------------------------------------------------------
1803 const char *mmgl_parser="title 'MGL parser sample'\n# call function\ncall 'sample'\n"
1804 "\n# ordinary for-loop\nfor $0 -1 1 0.1\n"
1805 "if $0<0:line 0 0 1 $0 'r':else:line 0 0 1 $0 'g':endif\nnext\n"
1806 "\n# if-elseif-else\nfor $i -1 1 0.5\nif $i<0\ntext 1.1 $i '$i' 'b'\n"
1807 "elseif $i>0\ntext 1.1 $i '$i' 'r'\nelse\ntext 1.1 $i '$i'\nendif\nnext\n"
1808 "\n# ordinary do-while\ndo\ndefnum $i $i-0.2\nline 0 0 $i 1 'b'\nwhile $i>0\n"
1809 "\n# do-next-break\ndo\ndefnum $i $i-0.2\nif $i<-1 then break\nline 0 0 $i 1 'm'\nnext\n"
1810 "\n# for-while-continue\nfor $i -5 10\ntext $i/5 1.1 'a'+($i+5)\nif $i<0\n"
1811 "text $i/5-0.06 1.1 '--' 'b'\nelseif mod($i,2)=0\ntext $i/5-0.06 1.1 '~' 'r'\n"
1812 "else\n# NOTE: 'continue' bypass the 'while'!\ncontinue\nendif\n"
1813 "# NOTE: 'while' limit the actual number of iterations\nwhile $i<5\n"
1814 "\n# nested loops\nfor $i 0 1 0.1\nfor $j 0 1 0.1\nball $i $j\n"
1815 "if $j>0.5 then continue\nball $i $j 'b+'\nnext\nnext\n"
1816 "\nfunc 'sample'\nnew dat 100 'sin(2*pi*(i/99+1))'\nplot dat;xrange -1 0\n"
1817 "box:axis\nxlabel 'x':ylabel 'y'\nreturn";
smgl_parser(mglGraph * gr)1818 void smgl_parser(mglGraph *gr)	// example of MGL parsing
1819 {	// NOTE: MGL version show much more variants of loops and conditions.
1820 	gr->Title("MGL parser sample");
1821 	double a[100];   // let a_i = sin(4*pi*x), x=0...1
1822 	for(int i=0;i<100;i++)a[i]=sin(2*M_PI*i/99);
1823 	mglParse *parser = new mglParse;
1824 	// Add MGL variable and set yours data to it.
1825 	mglData *d = dynamic_cast<mglData*>(parser->AddVar("dat"));
1826 	if(d)	d->Set(a,100);
1827 	parser->Execute(gr, "plot dat; xrange -1 0\nbox\naxis");
1828 	// You may break script at any line do something
1829 	// and continue after that.
1830 	parser->Execute(gr, "xlabel 'x'\nylabel 'y'\nbox");
1831 	// Also you may use cycles or conditions in script.
1832 	parser->Execute(gr, "for $0 -1 1 0.1\nif $0<0\n"
1833 		"line 0 0 1 $0 'r':else:line 0 0 1 $0 'g'\n"
1834 		"endif\nnext");
1835 	// You may use for or do-while loops as C/C++ one
1836 	double i=1;
1837 	do	{
1838 		char buf[64];	sprintf(buf,"line 0 0 %g 1 'b'",i);
1839 		parser->Execute(gr, buf);	i=i-0.2;
1840 	} while(i>0);
1841 	// or as MGL one.
1842 	parser->Execute(gr, "for $i -1 1 0.5\n"
1843 		"if $i<0\ntext 1.1 $i '$i' 'b'\n"
1844 		"elseif $i>0\ntext 1.1 $i '$i' 'r'\n"
1845 		"else\ntext 1.1 $i '$i'\nendif\nnext\n");
1846 	// There are 'break' and 'continue' commands in MGL too.
1847 	// NOTE: 'next' act as "while(1)" in do-while loops.
1848 	parser->Execute(gr, "do\ndefnum $i $i-0.2\n"
1849 		"if $i<-1 then break\nline 0 0 $i 1 'm'\nnext\n");
1850 	// One issue with 'continue' -- it bypass 'while' checking
1851 	parser->Execute(gr, "for $i -5 10\ntext $i/5 1.1 'a'+($i+5)\nif $i<0\n"
1852 		"text $i/5-0.06 1.1 '--' 'b'\n"
1853 		"elseif mod($i,2)=0\ntext $i/5-0.06 1.1 '~' 'r'\n"
1854 		"else\ncontinue\nendif\n"
1855 		// NOTE: 'while' limit the actual number of iterations in for-loop.
1856 		"while $i<5\n");
1857 	// Finally, MGL support nested loops too.
1858 	parser->Execute(gr, "for $i 0 1 0.1\nfor $j 0 1 0.1\nball $i $j\n"
1859 		"if $j>0.5 then continue\nball $i $j 'b+'\nnext\nnext\n");
1860 	// Clean up memory.
1861 	delete parser;
1862 }
1863 //-----------------------------------------------------------------------------
1864 const char *mmgl_belt="call 'prepare2d'\ntitle 'Belt plot':rotate 50 60:box:belt a";
smgl_belt(mglGraph * gr)1865 void smgl_belt(mglGraph *gr)
1866 {
1867 	mglData a;	mgls_prepare2d(&a);
1868 	if(big!=3)	gr->Title("Belt plot");
1869 	gr->Rotate(50,60);	gr->Box();	gr->Belt(a);
1870 }
1871 //-----------------------------------------------------------------------------
1872 const char *mmgl_beltc="call 'prepare2d'\ntitle 'BeltC plot':rotate 50 60:box:beltc a b";
smgl_beltc(mglGraph * gr)1873 void smgl_beltc(mglGraph *gr)
1874 {
1875 	mglData a,b;	mgls_prepare2d(&a,&b);
1876 	if(big!=3)	gr->Title("BeltC plot");
1877 	gr->Rotate(50,60);	gr->Box();	gr->BeltC(a,b);
1878 }
1879 //-----------------------------------------------------------------------------
1880 const char *mmgl_dens="call 'prepare2d'\nnew a1 30 40 3 '0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)'\n"
1881 "subplot 2 2 0 '':title 'Dens plot (default)':box:dens a\n"
1882 "subplot 2 2 1:title '3d variant':rotate 50 60:box:dens a\n"
1883 "subplot 2 2 2 '':title '\"\\#\" style; meshnum 10':box:dens a '#'; meshnum 10\n"
1884 "subplot 2 2 3:title 'several slices':rotate 50 60:box:dens a1";
smgl_dens(mglGraph * gr)1885 void smgl_dens(mglGraph *gr)
1886 {
1887 	mglData a,a1(30,40,3);	mgls_prepare2d(&a);
1888 	gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)");
1889 	if(big!=3)	{gr->SubPlot(2,2,0,"");	gr->Title("Dens plot (default)");}
1890 	gr->Box();	gr->Dens(a);
1891 	if(big==3)	return;
1892 	gr->SubPlot(2,2,1);	gr->Title("3d variant");
1893 	gr->Rotate(50,60);	gr->Box();	gr->Dens(a);
1894 	gr->SubPlot(2,2,2,"");	gr->Title("'\\#' style; meshnum 10");
1895 	gr->Box();	gr->Dens(a,"#","meshnum 10");
1896 	gr->SubPlot(2,2,3);	gr->Title("several slices");
1897 	gr->Rotate(50,60);		gr->Box();	gr->Dens(a1);
1898 }
1899 //-----------------------------------------------------------------------------
1900 const char *mmgl_surfc="call 'prepare2d'\ntitle 'SurfC plot':rotate 50 60:light on:box:surfc a b";
smgl_surfc(mglGraph * gr)1901 void smgl_surfc(mglGraph *gr)
1902 {
1903 	mglData a,b;	mgls_prepare2d(&a,&b);
1904 	if(big!=3)	gr->Title("SurfC plot");
1905 	gr->Rotate(50,60);	gr->Light(true);	gr->Box();	gr->SurfC(a,b);
1906 }
1907 //-----------------------------------------------------------------------------
1908 const char *mmgl_surfca="call 'prepare2d'\ntitle 'SurfCA plot':rotate 50 60:light on:alpha on:box:surfca a b a";
smgl_surfca(mglGraph * gr)1909 void smgl_surfca(mglGraph *gr)
1910 {
1911 	mglData a,b;	mgls_prepare2d(&a,&b);
1912 	if(big!=3)	gr->Title("SurfCA plot");
1913 	gr->Rotate(50,60);	gr->Alpha(true);	gr->Light(true);	gr->Box();
1914 	gr->SurfCA(a,b,a);
1915 }
1916 //-----------------------------------------------------------------------------
1917 const char *mmgl_surfa="call 'prepare2d'\ntitle 'SurfA plot':rotate 50 60:light on:alpha on:box:surfa a b";
smgl_surfa(mglGraph * gr)1918 void smgl_surfa(mglGraph *gr)
1919 {
1920 	mglData a,b;	mgls_prepare2d(&a,&b);
1921 	if(big!=3)	gr->Title("SurfA plot");
1922 	gr->Rotate(50,60);	gr->Alpha(true);	gr->Light(true);	gr->Box();
1923 	gr->SurfA(a,b);
1924 }
1925 //-----------------------------------------------------------------------------
1926 const char *mmgl_tile="call 'prepare2d'\ntitle 'Tile plot':rotate 50 60:box:tile a";
smgl_tile(mglGraph * gr)1927 void smgl_tile(mglGraph *gr)
1928 {
1929 	mglData a;	mgls_prepare2d(&a);
1930 	if(big!=3)	gr->Title("Tile plot");
1931 	gr->Rotate(40,60);	gr->Box();	gr->Tile(a);
1932 }
1933 //-----------------------------------------------------------------------------
1934 const char *mmgl_tiles="call 'prepare2d'\nsubplot 1 1 0 '':title 'Tiles plot':box:tiles a b";
smgl_tiles(mglGraph * gr)1935 void smgl_tiles(mglGraph *gr)
1936 {
1937 	mglData a,b;	mgls_prepare2d(&a,&b);
1938 	if(big!=3)	{gr->SubPlot(1,1,0,"");	gr->Title("TileS plot");}
1939 	gr->Box();	gr->TileS(a,b);
1940 }
1941 //-----------------------------------------------------------------------------
1942 const char *mmgl_boxs="call 'prepare2d'\norigin 0 0 0\nsubplot 2 2 0:title 'Boxs plot (default)':rotate 40 60:light on:box:boxs a\n"
1943 "subplot 2 2 1:title '\"\\@\" style':rotate 50 60:box:boxs a '@'\n"
1944 "subplot 2 2 2:title '\"\\#\" style':rotate 50 60:box:boxs a '#'\n"
1945 "subplot 2 2 3:title 'compare with Tile':rotate 50 60:box:tile a";
smgl_boxs(mglGraph * gr)1946 void smgl_boxs(mglGraph *gr)
1947 {
1948 	mglData a;	mgls_prepare2d(&a);
1949 	gr->SetOrigin(0,0,0);	gr->Light(true);
1950 	if(big!=3)	{gr->SubPlot(2,2,0);	gr->Title("Boxs plot (default)");}
1951 	gr->Rotate(40,60);	gr->Box();	gr->Boxs(a);
1952 	if(big==3)	return;
1953 	gr->SubPlot(2,2,1);	gr->Title("'\\@' style");
1954 	gr->Rotate(50,60);	gr->Box();	gr->Boxs(a,"@");
1955 	gr->SubPlot(2,2,2);	gr->Title("'\\#' style");
1956 	gr->Rotate(50,60);	gr->Box();	gr->Boxs(a,"#");
1957 	gr->SubPlot(2,2,3);	gr->Title("compare with Tile");
1958 	gr->Rotate(50,60);	gr->Box();	gr->Tile(a);
1959 }
1960 //-----------------------------------------------------------------------------
1961 const char *mmgl_fit="new dat 100 '0.4*rnd+0.1+sin(2*pi*x)'\nnew in 100 '0.3+sin(2*pi*x)'\n"
1962 "list ini 1 1 3:fit res dat 'a+b*sin(c*x)' 'abc' ini\n"
1963 "title 'Fitting sample':yrange -2 2:box:axis:plot dat 'k. '\n"
1964 "plot res 'r':plot in 'b'\ntext -0.9 -1.3 'fitted:' 'r:L'\n"
1965 "putsfit 0 -1.8 'y = ' 'r':text 0 2.2 'initial: y = 0.3+sin(2\\pi x)' 'b'";
smgl_fit(mglGraph * gr)1966 void smgl_fit(mglGraph *gr)	// nonlinear fitting
1967 {
1968 	mglData dat(100), in(100), res;
1969 	gr->Fill(dat,"0.4*rnd+0.1+sin(2*pi*x)");
1970 	gr->Fill(in,"0.3+sin(2*pi*x)");
1971 	double ini[3] = {1,1,3};
1972 	mglData Ini(3,ini);
1973 	res = gr->Fit(dat, "a+b*sin(c*x)", "abc", Ini);
1974 	if(big!=3)	gr->Title("Fitting sample");
1975 	gr->SetRange('y',-2,2);	gr->Box();	gr->Plot(dat, "k. ");
1976 	gr->Axis();		gr->Plot(res, "r");	gr->Plot(in, "b");
1977 	gr->Puts(mglPoint(-0.9, -1.3), "fitted:", "r:L");
1978 	gr->PutsFit(mglPoint(0, -1.8), "y = ", "r");
1979 	gr->Puts(mglPoint(0, 2.2), "initial: y = 0.3+sin(2\\pi x)", "b");
1980 //	gr->SetRanges(mglPoint(-1,-1,-1),mglPoint(1,1,1));	gr->SetOrigin(0,0,0);
1981 }
1982 //-----------------------------------------------------------------------------
1983 const char *mmgl_vect3="call 'prepare3v'\nsubplot 2 1 0:title 'Vect3 sample':rotate 50 60\n"
1984 "origin 0 0 0:box:axis '_xyz'\nvect3 ex ey ez 'x':vect3 ex ey ez:vect3 ex ey ez 'z'\n"
1985 "subplot 2 1 1:title '\"f\" style':rotate 50 60\n"
1986 "origin 0 0 0:box:axis '_xyz'\nvect3 ex ey ez 'fx':vect3 ex ey ez 'f':vect3 ex ey ez 'fz'\n"
1987 "grid3 ex 'Wx':grid3 ex 'W':grid3 ex 'Wz'";
smgl_vect3(mglGraph * gr)1988 void smgl_vect3(mglGraph *gr)
1989 {
1990 	mglData ex,ey,ez;	mgls_prepare3v(&ex,&ey,&ez);
1991 	if(big!=3)	{	gr->SubPlot(2,1,0);	gr->Title("Vect3 sample");	}
1992 	gr->Rotate(50,60);	gr->SetOrigin(0,0,0);	gr->Axis("_xyz");	gr->Box();
1993 	gr->Vect3(ex,ey,ez,"x");	gr->Vect3(ex,ey,ez);	gr->Vect3(ex,ey,ez,"z");
1994 	if(big==3)	return;
1995 	gr->SubPlot(2,1,1);	gr->Title("'f' style");
1996 	gr->Rotate(50,60);	gr->SetOrigin(0,0,0);	gr->Axis("_xyz");	gr->Box();
1997 	gr->Vect3(ex,ey,ez,"fx");	gr->Vect3(ex,ey,ez,"f");	gr->Vect3(ex,ey,ez,"fz");
1998 	gr->Grid3(ex,"Wx");	gr->Grid3(ex,"W");	gr->Grid3(ex,"Wz");
1999 }
2000 //-----------------------------------------------------------------------------
2001 const char *mmgl_vect="call 'prepare2v'\ncall 'prepare3v'\nsubplot 3 2 0 '':title 'Vect plot (default)':box:vect a b\n"
2002 "subplot 3 2 1 '':title '\".\" style; \"=\" style':box:vect a b '.='\n"
2003 "subplot 3 2 2 '':title '\"f\" style':box:vect a b 'f'\n"
2004 "subplot 3 2 3 '':title '\">\" style':box:vect a b '>'\n"
2005 "subplot 3 2 4 '':title '\"<\" style':box:vect a b '<'\n"
2006 "subplot 3 2 5:title '3d variant':rotate 50 60:box:vect ex ey ez";
smgl_vect(mglGraph * gr)2007 void smgl_vect(mglGraph *gr)
2008 {
2009 	mglData a,b;	mgls_prepare2v(&a,&b);
2010 	if(big!=3)	{gr->SubPlot(3,2,0,"");	gr->Title("Vect plot (default)");}
2011 	gr->Box();	gr->Vect(a,b);
2012 	if(big==3)	return;
2013 	gr->SubPlot(3,2,1,"");	gr->Title("'.' style; '=' style");	gr->Box();	gr->Vect(a,b,"=.");
2014 	gr->SubPlot(3,2,2,"");	gr->Title("'f' style");
2015 	gr->Box();	gr->Vect(a,b,"f");
2016 	gr->SubPlot(3,2,3,"");	gr->Title("'>' style");
2017 	gr->Box();	gr->Vect(a,b,">");
2018 	gr->SubPlot(3,2,4,"");	gr->Title("'<' style");
2019 	gr->Box();	gr->Vect(a,b,"<");
2020 	mglData ex,ey,ez;	mgls_prepare3v(&ex,&ey,&ez);
2021 	gr->SubPlot(3,2,5);	gr->Title("3d variant");	gr->Rotate(50,60);
2022 	gr->Box();	gr->Vect(ex,ey,ez);
2023 }
2024 //-----------------------------------------------------------------------------
2025 const char *mmgl_flow="call 'prepare2v'\ncall 'prepare3v'\nsubplot 2 2 0 '':title 'Flow plot (default)':box:flow a b\n"
2026 "subplot 2 2 1 '':title '\"v\" style':box:flow a b 'v'\n"
2027 "subplot 2 2 2 '':title '\"#\" and \".\" styles':box:flow a b '#':flow a b '.2k'\n"
2028 "subplot 2 2 3:title '3d variant':rotate 50 60:box:flow ex ey ez";
smgl_flow(mglGraph * gr)2029 void smgl_flow(mglGraph *gr)
2030 {
2031 	mglData a,b;	mgls_prepare2v(&a,&b);
2032 	if(big!=3)	{gr->SubPlot(2,2,0,"");	gr->Title("Flow plot (default)");}
2033 	gr->Box();	gr->Flow(a,b);
2034 	if(big==3)	return;
2035 	gr->SubPlot(2,2,1,"");	gr->Title("'v' style");
2036 	gr->Box();	gr->Flow(a,b,"v");
2037 	gr->SubPlot(2,2,2,"");	gr->Title("'\\#' and '.' styles");
2038 	gr->Box();	gr->Flow(a,b,"#");	gr->Flow(a,b,".2k");
2039 	mglData ex,ey,ez;	mgls_prepare3v(&ex,&ey,&ez);
2040 	gr->SubPlot(2,2,3);	gr->Title("3d variant");	gr->Rotate(50,60);
2041 	gr->Box();	gr->Flow(ex,ey,ez);
2042 }
2043 //-----------------------------------------------------------------------------
2044 const char *mmgl_flow3="call 'prepare3v'\n"
2045 "subplot 2 2 0:title 'Flow3 plot (default)':rotate 50 60:box\nflow3 ex ey ez\n"
2046 "subplot 2 2 1:title '\"v\" style, from boundary':rotate 50 60:box\nflow3 ex ey ez 'v' 0\n"
2047 "subplot 2 2 2:title '\"t\" style':rotate 50 60:box\nflow3 ex ey ez 't' 0\n"
2048 "subplot 2 2 3:title 'from \\i z planes':rotate 50 60:box\nflow3 ex ey ez 'z' 0\nflow3 ex ey ez 'z' 9";
smgl_flow3(mglGraph * gr)2049 void smgl_flow3(mglGraph *gr)
2050 {
2051 	mglData ex,ey,ez;	mgls_prepare3v(&ex,&ey,&ez);
2052 	if(big!=3)	{gr->SubPlot(2,2,0);	gr->Title("Flow3 plot (default)");}
2053 	gr->Rotate(50,60);	gr->Box();		gr->Flow3(ex,ey,ez);
2054 	if(big==3)	return;
2055 	gr->SubPlot(2,2,1);	gr->Title("'v' style, from boundary");
2056 	gr->Rotate(50,60);	gr->Box();	gr->Flow3(ex,ey,ez,"v",0);
2057 	gr->SubPlot(2,2,2);	gr->Title("'t' style");
2058 	gr->Rotate(50,60);	gr->Box();	gr->Flow3(ex,ey,ez,"t",0);
2059 	gr->SubPlot(2,2,3);	gr->Title("from \\i z planes");
2060 	gr->Rotate(50,60);	gr->Box();	gr->Flow3(ex,ey,ez,"z",0);	gr->Flow3(ex,ey,ez,"z",9);
2061 }
2062 //-----------------------------------------------------------------------------
2063 const char *mmgl_pipe="call 'prepare2v'\ncall 'prepare3v'\nsubplot 2 2 0 '':title 'Pipe plot (default)':light on:box:pipe a b\n"
2064 "subplot 2 2 1 '':title '\"i\" style':box:pipe a b 'i'\n"
2065 "subplot 2 2 2 '':title 'from edges only':box:pipe a b '#'\n"
2066 "subplot 2 2 3:title '3d variant':rotate 50 60:box:pipe ex ey ez '' 0.1";
smgl_pipe(mglGraph * gr)2067 void smgl_pipe(mglGraph *gr)
2068 {
2069 	mglData a,b;	mgls_prepare2v(&a,&b);
2070 	if(big!=3)	{gr->SubPlot(2,2,0,"");	gr->Title("Pipe plot (default)");}
2071 	gr->Light(true);	gr->Box();	gr->Pipe(a,b);
2072 	if(big==3)	return;
2073 	gr->SubPlot(2,2,1,"");	gr->Title("'i' style");	gr->Box();	gr->Pipe(a,b,"i");
2074 	gr->SubPlot(2,2,2,"");	gr->Title("'\\#' style");	gr->Box();	gr->Pipe(a,b,"#");
2075 	mglData ex,ey,ez;	mgls_prepare3v(&ex,&ey,&ez);
2076 	gr->SubPlot(2,2,3);	gr->Title("3d variant");	gr->Rotate(50,60);
2077 	gr->Box();	gr->Pipe(ex,ey,ez,"",0.1);
2078 }
2079 //-----------------------------------------------------------------------------
2080 const char *mmgl_dew="call 'prepare2v'\nsubplot 1 1 0 '':title 'Dew plot':light on:box:dew a b";
smgl_dew(mglGraph * gr)2081 void smgl_dew(mglGraph *gr)
2082 {
2083 	mglData a,b;	mgls_prepare2v(&a,&b);
2084 	if(big!=3)	{gr->SubPlot(1,1,0,"");	gr->Title("Dew plot");}
2085 	gr->Box();	gr->Light(true);	gr->Dew(a,b);
2086 }
2087 //-----------------------------------------------------------------------------
2088 const char *mmgl_grad="call 'prepare2d'\nsubplot 1 1 0 '':title 'Grad plot':box:grad a:dens a '{u8}w{q8}'";
smgl_grad(mglGraph * gr)2089 void smgl_grad(mglGraph *gr)
2090 {
2091 	mglData a;	mgls_prepare2d(&a);
2092 	if(big!=3)	{gr->SubPlot(1,1,0,"");	gr->Title("Grad plot");}
2093 	gr->Box();	gr->Grad(a);	gr->Dens(a,"{u8}w{q8}");
2094 }
2095 //-----------------------------------------------------------------------------
2096 const char *mmgl_cones="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd'\nlight on:origin 0 0 0\n"
2097 "subplot 3 2 0:title 'Cones plot':rotate 50 60:box:cones ys\n"
2098 "subplot 3 2 1:title '2 colors':rotate 50 60:box:cones ys 'cbgGyr'\n"
2099 "subplot 3 2 2:title '\"\\#\" style':rotate 50 60:box:cones ys '#'\n"
2100 "subplot 3 2 3:title '\"a\" style':rotate 50 60:zrange -2 2:box:cones ys 'a'\n"
2101 "subplot 3 2 4:title '\"t\" style':rotate 50 60:box:cones ys 't'\n"
2102 "subplot 3 2 5:title '\"4\" style':rotate 50 60:box:cones ys '4'";
smgl_cones(mglGraph * gr)2103 void smgl_cones(mglGraph *gr)
2104 {
2105 	mglData ys(10,3);	ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
2106 	gr->Light(true);	gr->SetOrigin(0,0,0);
2107 	if(big!=3)	{	gr->SubPlot(3,2,0);	gr->Title("Cones plot");	}
2108 	gr->Rotate(50,60);	gr->Box();	gr->Cones(ys);
2109 	if(big==3)	return;
2110 	gr->SubPlot(3,2,1);	gr->Title("2 colors");
2111 	gr->Rotate(50,60);	gr->Box();	gr->Cones(ys,"cbgGyr");
2112 	gr->SubPlot(3,2,2);	gr->Title("'\\#' style");
2113 	gr->Rotate(50,60);	gr->Box();	gr->Cones(ys,"#");
2114 	gr->SubPlot(3,2,3);	gr->Title("'a' style");
2115 	gr->SetRange('z',-2,2);	// increase range since summation can exceed [-1,1]
2116 	gr->Rotate(50,60);	gr->Box();	gr->Cones(ys,"a");
2117 	gr->SubPlot(3,2,4);	gr->Title("'t' style");
2118 	gr->Rotate(50,60);	gr->Box();	gr->Cones(ys,"t");
2119 	gr->SubPlot(3,2,5);	gr->Title("'4' style");
2120 	gr->Rotate(50,60);	gr->Box();	gr->Cones(ys,"4");
2121 }
2122 //-----------------------------------------------------------------------------
2123 const char *mmgl_aspect="subplot 2 2 0:box:text -1 1.1 'Just box' ':L'\n"
2124 "inplot 0.2 0.5 0.7 1 off:box:text 0 1.2 'InPlot example'\n"
2125 "subplot 2 2 1:title 'Rotate only':rotate 50 60:box\n"
2126 "subplot 2 2 2:title 'Rotate and Aspect':rotate 50 60:aspect 1 1 2:box\n"
2127 "subplot 2 2 3:title 'Shear':box 'c':shear 0.2 0.1:box";
smgl_aspect(mglGraph * gr)2128 void smgl_aspect(mglGraph *gr)	// transformation
2129 {
2130 	gr->SubPlot(2,2,0);	gr->Box();
2131 	gr->Puts(mglPoint(-1,1.1),"Just box",":L");
2132 	gr->InPlot(0.2,0.5,0.7,1,false);	gr->Box();
2133 	gr->Puts(mglPoint(0,1.2),"InPlot example");
2134 	gr->SubPlot(2,2,1);	gr->Title("Rotate only");
2135 	gr->Rotate(50,60);	gr->Box();
2136 	gr->SubPlot(2,2,2);	gr->Title("Rotate and Aspect");
2137 	gr->Rotate(50,60);	gr->Aspect(1,1,2);	gr->Box();
2138 	gr->SubPlot(2,2,3);	gr->Title("Shear");
2139 	gr->Box("c");		gr->Shear(0.2,0.1);	gr->Box();
2140 }
2141 //-----------------------------------------------------------------------------
2142 const char *mmgl_inplot="subplot 3 2 0:title 'StickPlot'\nstickplot 3 0 20 30:box 'r':text 0 0 0 '0' 'r'\n"
2143 "stickplot 3 1 20 30:box 'g':text 0 0 0 '1' 'g'\nstickplot 3 2 20 30:box 'b':text 0 9 0 '2' 'b'\n"
2144 "subplot 3 2 3 '':title 'ColumnPlot'\ncolumnplot 3 0:box 'r':text 0 0 '0' 'r'\n"
2145 "columnplot 3 1:box 'g':text 0 0 '1' 'g'\ncolumnplot 3 2:box 'b':text 0 0 '2' 'b'\n"
2146 "subplot 3 2 4 '':title 'GridPlot'\ngridplot 2 2 0:box 'r':text 0 0 '0' 'r'\n"
2147 "gridplot 2 2 1:box 'g':text 0 0 '1' 'g'\ngridplot 2 2 2:box 'b':text 0 0 '2' 'b'\n"
2148 "gridplot 2 2 3:box 'm':text 0 0 '3' 'm'\nsubplot 3 2 5 '':title 'InPlot':box\n"
2149 "inplot 0.4 1 0.6 1 on:box 'r'\nmultiplot 3 2 1 2 1 '':title 'MultiPlot and ShearPlot':box\n"
2150 "shearplot 3 0 0.2 0.1:box 'r':text 0 0 '0' 'r'\nshearplot 3 1 0.2 0.1:box 'g':text 0 0 '1' 'g'\n"
2151 "shearplot 3 2 0.2 0.1:box 'b':text 0 0 '2' 'b'";
smgl_inplot(mglGraph * gr)2152 void smgl_inplot(mglGraph *gr)
2153 {
2154 	gr->SubPlot(3,2,0);	gr->Title("StickPlot");
2155 	gr->StickPlot(3, 0, 20, 30);	gr->Box("r");	gr->Puts(mglPoint(0),"0","r");
2156 	gr->StickPlot(3, 1, 20, 30);	gr->Box("g");	gr->Puts(mglPoint(0),"1","g");
2157 	gr->StickPlot(3, 2, 20, 30);	gr->Box("b");	gr->Puts(mglPoint(0),"2","b");
2158 	gr->SubPlot(3,2,3,"");	gr->Title("ColumnPlot");
2159 	gr->ColumnPlot(3, 0);	gr->Box("r");	gr->Puts(mglPoint(0),"0","r");
2160 	gr->ColumnPlot(3, 1);	gr->Box("g");	gr->Puts(mglPoint(0),"1","g");
2161 	gr->ColumnPlot(3, 2);	gr->Box("b");	gr->Puts(mglPoint(0),"2","b");
2162 	gr->SubPlot(3,2,4,"");	gr->Title("GridPlot");
2163 	gr->GridPlot(2, 2, 0);	gr->Box("r");	gr->Puts(mglPoint(0),"0","r");
2164 	gr->GridPlot(2, 2, 1);	gr->Box("g");	gr->Puts(mglPoint(0),"1","g");
2165 	gr->GridPlot(2, 2, 2);	gr->Box("b");	gr->Puts(mglPoint(0),"2","b");
2166 	gr->GridPlot(2, 2, 3);	gr->Box("m");	gr->Puts(mglPoint(0),"3","m");
2167 	gr->SubPlot(3,2,5,"");	gr->Title("InPlot");	gr->Box();
2168 	gr->InPlot(0.4, 1, 0.6, 1, true);	gr->Box("r");
2169 	gr->MultiPlot(3,2,1, 2, 1,"");	gr->Title("MultiPlot and ShearPlot");	gr->Box();
2170 	gr->ShearPlot(3, 0, 0.2, 0.1);	gr->Box("r");	gr->Puts(mglPoint(0),"0","r");
2171 	gr->ShearPlot(3, 1, 0.2, 0.1);	gr->Box("g");	gr->Puts(mglPoint(0),"1","g");
2172 	gr->ShearPlot(3, 2, 0.2, 0.1);	gr->Box("b");	gr->Puts(mglPoint(0),"2","b");
2173 }
2174 //-----------------------------------------------------------------------------
2175 const char *mmgl_combined="call 'prepare2v'\ncall 'prepare3d'\nnew v 10:fill v -0.5 1:copy d sqrt(a^2+b^2)\n"
2176 "subplot 2 2 0:title 'Surf + Cont':rotate 50 60:light on:box:surf a:cont a 'y'\n"
2177 "subplot 2 2 1 '':title 'Flow + Dens':light off:box:flow a b 'br':dens d\n"
2178 "subplot 2 2 2:title 'Mesh + Cont':rotate 50 60:box:mesh a:cont a '_'\n"
2179 "subplot 2 2 3:title 'Surf3 + ContF3':rotate 50 60:light on\n"
2180 "box:contf3 v c 'z' 0:contf3 v c 'x':contf3 v c\ncut 0 -1 -1 1 0 1.1\ncontf3 v c 'z' c.nz-1:surf3 c -0.5";
smgl_combined(mglGraph * gr)2181 void smgl_combined(mglGraph *gr)	// flow threads and density plot
2182 {
2183 	mglData a,b,d;	mgls_prepare2v(&a,&b);	d = a;
2184 	for(int i=0;i<a.nx*a.ny;i++)	d.a[i] = hypot(a.a[i],b.a[i]);
2185 	mglData c;	mgls_prepare3d(&c);
2186 	mglData v(10);	v.Fill(-0.5,1);
2187 	gr->SubPlot(2,2,1,"");	gr->Title("Flow + Dens");
2188 	gr->Flow(a,b,"br");	gr->Dens(d);	gr->Box();
2189 	gr->SubPlot(2,2,0);	gr->Title("Surf + Cont");	gr->Rotate(50,60);
2190 	gr->Light(true);	gr->Surf(a);	gr->Cont(a,"y");	gr->Box();
2191 	gr->SubPlot(2,2,2);	gr->Title("Mesh + Cont");	gr->Rotate(50,60);
2192 	gr->Box();	gr->Mesh(a);	gr->Cont(a,"_");
2193 	gr->SubPlot(2,2,3);	gr->Title("Surf3 + ContF3");gr->Rotate(50,60);
2194 	gr->Box();	gr->ContF3(v,c,"z",0);	gr->ContF3(v,c,"x");	gr->ContF3(v,c);
2195 	gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1));
2196 	gr->ContF3(v,c,"z",c.nz-1);	gr->Surf3(-0.5,c);
2197 }
2198 //-----------------------------------------------------------------------------
2199 const char *mmgl_axis="subplot 2 2 0:title 'Axis origin, Grid':origin 0 0:axis:grid:fplot 'x^3'\n"
2200 "subplot 2 2 1:title '2 axis':ranges -1 1 -1 1:origin -1 -1:axis:ylabel 'axis_1':fplot 'sin(pi*x)' 'r2'\n"
2201 "ranges 0 1 0 1:origin 1 1:axis:ylabel 'axis_2':fplot 'cos(pi*x)'\n"
2202 "subplot 2 2 3:title 'More axis':origin nan nan:xrange -1 1:axis:xlabel 'x' 0:ylabel 'y_1' 0:fplot 'x^2' 'k'\n"
2203 "yrange -1 1:origin -1.3 -1:axis 'y' 'r':ylabel '#r{y_2}' 0.2:fplot 'x^3' 'r'\n\n"
2204 "subplot 2 2 2:title '4 segments, inverted axis':origin 0 0:\n"
2205 "inplot 0.5 1 0.5 1 on:ranges 0 10 0 2:axis\nfplot 'sqrt(x/2)':xlabel 'W' 1:ylabel 'U' 1\n"
2206 "inplot 0 0.5 0.5 1 on:ranges 1 0 0 2:axis 'x':fplot 'sqrt(x)+x^3':xlabel '\\tau' 1\n"
2207 "inplot 0.5 1 0 0.5 on:ranges 0 10 4 0:axis 'y':fplot 'x/4':ylabel 'L' -1\n"
2208 "inplot 0 0.5 0 0.5 on:ranges 1 0 4 0:fplot '4*x^2'";
smgl_axis(mglGraph * gr)2209 void smgl_axis(mglGraph *gr)
2210 {
2211 	gr->SubPlot(2,2,0);	gr->Title("Axis origin, Grid");	gr->SetOrigin(0,0);
2212 	gr->Axis();	gr->Grid();	gr->FPlot("x^3");
2213 
2214 	gr->SubPlot(2,2,1);	gr->Title("2 axis");
2215 	gr->SetRanges(-1,1,-1,1);	gr->SetOrigin(-1,-1,-1);	// first axis
2216 	gr->Axis();	gr->Label('y',"axis 1",0);	gr->FPlot("sin(pi*x)","r2");
2217 	gr->SetRanges(0,1,0,1);		gr->SetOrigin(1,1,1);		// second axis
2218 	gr->Axis();	gr->Label('y',"axis 2",0);	gr->FPlot("cos(pi*x)");
2219 
2220 	gr->SubPlot(2,2,3);	gr->Title("More axis");	gr->SetOrigin(NAN,NAN);	gr->SetRange('x',-1,1);
2221 	gr->Axis();	gr->Label('x',"x",0);	gr->Label('y',"y_1",0);	gr->FPlot("x^2","k");
2222 	gr->SetRanges(-1,1,-1,1);	gr->SetOrigin(-1.3,-1);	// second axis
2223 	gr->Axis("y","r");	gr->Label('y',"#r{y_2}",0.2);	gr->FPlot("x^3","r");
2224 
2225 	gr->SubPlot(2,2,2);	gr->Title("4 segments, inverted axis");		gr->SetOrigin(0,0);
2226 	gr->InPlot(0.5,1,0.5,1);	gr->SetRanges(0,10,0,2);	gr->Axis();
2227 	gr->FPlot("sqrt(x/2)");		gr->Label('x',"W",1);	gr->Label('y',"U",1);
2228 	gr->InPlot(0,0.5,0.5,1);	gr->SetRanges(1,0,0,2);	gr->Axis("x");
2229 	gr->FPlot("sqrt(x)+x^3");	gr->Label('x',"\\tau",-1);
2230 	gr->InPlot(0.5,1,0,0.5);	gr->SetRanges(0,10,4,0);	gr->Axis("y");
2231 	gr->FPlot("x/4");	gr->Label('y',"L",-1);
2232 	gr->InPlot(0,0.5,0,0.5);	gr->SetRanges(1,0,4,0);	gr->FPlot("4*x^2");
2233 }
2234 //-----------------------------------------------------------------------------
2235 const char *mmgl_ticks="subplot 3 3 0:title 'Usual axis with \":\" style'\naxis ':'\n\n"
2236 "subplot 3 3 1:title 'Too big/small range'\nranges -1000 1000 0 0.001:axis\n\n"
2237 "subplot 3 3 2:title 'LaTeX-like labels'\naxis 'F!'\n\n"
2238 "subplot 3 3 3:title 'Too narrow range'\nranges 100 100.1 10 10.01:axis\n\n"
2239 "subplot 3 3 4:title 'No tuning, manual \"+\"'\naxis '+!'\n"
2240 "# for version <2.3 you can use\n#tuneticks off:axis\n\n"
2241 "subplot 3 3 5:title 'Template for ticks'\nxtick 'xxx:%g':ytick 'y:%g'\naxis\n\n"
2242 "xtick '':ytick '' # switch it off for other plots\n\n"
2243 "subplot 3 3 6:title 'No tuning, higher precision'\naxis '!4'\n\n"
2244 "subplot 3 3 7:title 'Manual ticks'\nranges -pi pi 0 2\n"
2245 "xtick pi 3 '\\pi'\nxtick 0.886 'x^*' on # note this will disable subticks drawing\n"
2246 "# or you can use\n#xtick -pi '\\pi' -pi/2 '-\\pi/2' 0 '0' 0.886 'x^*' pi/2 '\\pi/2' pi 'pi'\n"
2247 "list v 0 0.5 1 2:ytick v '0\n0.5\n1\n2'\n"
2248 "axis:grid:fplot '2*cos(x^2)^2' 'r2'\n\n"
2249 "subplot 3 3 8:title 'Time ticks'\nxrange 0 3e5:ticktime 'x':axis";
smgl_ticks(mglGraph * gr)2250 void smgl_ticks(mglGraph *gr)
2251 {
2252 	gr->SubPlot(3,3,0);	gr->Title("Usual axis with ':' style");	gr->Axis(":");
2253 	gr->SubPlot(3,3,1);	gr->Title("Too big/small range");
2254 	gr->SetRanges(-1000,1000,0,0.001);	gr->Axis();
2255 	gr->SubPlot(3,3,2);	gr->Title("LaTeX-like labels");
2256 	gr->Axis("F!");
2257 	gr->SubPlot(3,3,3);	gr->Title("Too narrow range");
2258 	gr->SetRanges(100,100.1,10,10.01);	gr->Axis();
2259 	gr->SubPlot(3,3,4);	gr->Title("No tuning, manual '+'");
2260 	// for version<2.3 you need first call gr->SetTuneTicks(0);
2261 	gr->Axis("+!");
2262 	gr->SubPlot(3,3,5);	gr->Title("Template for ticks");
2263 	gr->SetTickTempl('x',"xxx:%g");	gr->SetTickTempl('y',"y:%g");
2264 	gr->Axis();
2265 	// now switch it off for other plots
2266 	gr->SetTickTempl('x',"");	gr->SetTickTempl('y',"");
2267 	gr->SubPlot(3,3,6);	gr->Title("No tuning, higher precision");
2268 	gr->Axis("!4");
2269 	gr->SubPlot(3,3,7);	gr->Title("Manual ticks");	gr->SetRanges(-M_PI,M_PI, 0, 2);
2270 	gr->SetTicks('x',M_PI,0,0,"\\pi");	gr->AddTick('x',0.886,"x^*");
2271 	// alternatively you can use following lines
2272 	double val[]={0, 0.5, 1, 2};
2273 	gr->SetTicksVal('y', mglData(4,val), "0\n0.5\n1\n2");
2274 	gr->Axis();	gr->Grid();	gr->FPlot("2*cos(x^2)^2", "r2");
2275 	gr->SubPlot(3,3,8);	gr->Title("Time ticks");	gr->SetRange('x',0,3e5);
2276 	gr->SetTicksTime('x',0);	gr->Axis();
2277 }
2278 //-----------------------------------------------------------------------------
2279 const char *mmgl_box="subplot 2 2 0:title 'Box (default)':rotate 50 60:box\n"
2280 "subplot 2 2 1:title 'colored':rotate 50 60:box 'r'\n"
2281 "subplot 2 2 2:title 'with faces':rotate 50 60:box '@'\n"
2282 "subplot 2 2 3:title 'both':rotate 50 60:box '@cm'";
smgl_box(mglGraph * gr)2283 void smgl_box(mglGraph *gr)
2284 {
2285 	gr->SubPlot(2,2,0);	gr->Title("Box (default)");	gr->Rotate(50,60);	gr->Box();
2286 	gr->SubPlot(2,2,1);	gr->Title("colored");		gr->Rotate(50,60);	gr->Box("r");
2287 	gr->SubPlot(2,2,2);	gr->Title("with faces");	gr->Rotate(50,60);	gr->Box("@");
2288 	gr->SubPlot(2,2,3);	gr->Title("both");	gr->Rotate(50,60);	gr->Box("@cm");
2289 }
2290 //-----------------------------------------------------------------------------
2291 const char *mmgl_loglog="subplot 2 2 0 '<_':title 'Semi-log axis':ranges 0.01 100 -1 1:axis 'lg(x)' '' ''\n"
2292 "axis:grid 'xy' 'g':fplot 'sin(1/x)':xlabel 'x' 0:ylabel 'y = sin 1/x' 0\n"
2293 "subplot 2 2 1 '<_':title 'Log-log axis':ranges 0.01 100 0.1 100:axis 'lg(x)' 'lg(y)' ''\n"
2294 "axis:grid '!' 'h=':grid:fplot 'sqrt(1+x^2)'\nxlabel 'x' 0:ylabel 'y = \\sqrt{1+x^2}' 0\n"
2295 "subplot 2 2 2 '<_':title 'Minus-log axis':ranges -100 -0.01 -100 -0.1:axis '-lg(-x)' '-lg(-y)' ''\n"
2296 "axis:fplot '-sqrt(1+x^2)':xlabel 'x' 0:ylabel 'y = -\\sqrt{1+x^2}' 0\n"
2297 "subplot 2 2 3 '<_':title 'Log-ticks':ranges 0.01 100 0 100:axis 'sqrt(x)' '' ''\n"
2298 "axis:fplot 'x':xlabel 'x' 1:ylabel 'y = x' 0";
smgl_loglog(mglGraph * gr)2299 void smgl_loglog(mglGraph *gr)	// log-log axis
2300 {
2301 	gr->SubPlot(2,2,0,"<_");	gr->Title("Semi-log axis");	gr->SetRanges(0.01,100,-1,1);	gr->SetFunc("lg(x)","");
2302 	gr->Axis();	gr->Grid("xy","g");	gr->FPlot("sin(1/x)");	gr->Label('x',"x",0); gr->Label('y', "y = sin 1/x",0);
2303 	gr->SubPlot(2,2,1,"<_");	gr->Title("Log-log axis");	gr->SetRanges(0.01,100,0.1,100);	gr->SetFunc("lg(x)","lg(y)");
2304 	gr->Axis();	gr->Grid("!","h=");	gr->Grid();	gr->FPlot("sqrt(1+x^2)");	gr->Label('x',"x",0); gr->Label('y', "y = \\sqrt{1+x^2}",0);
2305 	gr->SubPlot(2,2,2,"<_");	gr->Title("Minus-log axis");	gr->SetRanges(-100,-0.01,-100,-0.1);	gr->SetFunc("-lg(-x)","-lg(-y)");
2306 	gr->Axis();	gr->FPlot("-sqrt(1+x^2)");	gr->Label('x',"x",0); gr->Label('y', "y = -\\sqrt{1+x^2}",0);
2307 	gr->SubPlot(2,2,3,"<_");	gr->Title("Log-ticks");	gr->SetRanges(0.1,100,0,100);	gr->SetFunc("sqrt(x)","");
2308 	gr->Axis();	gr->FPlot("x");	gr->Label('x',"x",1); gr->Label('y', "y = x",0);
2309 }
2310 //-----------------------------------------------------------------------------
2311 const char *mmgl_venn="list x -0.3 0 0.3:list y 0.3 -0.3 0.3:list e 0.7 0.7 0.7\n"
2312 "subplot 1 1 0:title 'Venn-like diagram'\ntransptype 1:alpha on:error x y e e '!rgb@#o';alpha 0.1";
smgl_venn(mglGraph * gr)2313 void smgl_venn(mglGraph *gr)
2314 {
2315 	double xx[3]={-0.3,0,0.3}, yy[3]={0.3,-0.3,0.3}, ee[3]={0.7,0.7,0.7};
2316 	mglData x(3,xx), y(3,yy), e(3,ee);
2317 	gr->SubPlot(1,1,0);	gr->Title("Venn-like diagram");
2318 	gr->SetTranspType(1);	gr->Alpha(true);	gr->Error(x,y,e,e,"!rgb@#o","alpha 0.1");
2319 }
2320 //-----------------------------------------------------------------------------
2321 const char *mmgl_stereo="call 'prepare2d'\nlight on\nsubplot 2 1 0:rotate 50 60+1:box:surf a\nsubplot 2 1 1:rotate 50 60-1:box:surf a";
smgl_stereo(mglGraph * gr)2322 void smgl_stereo(mglGraph *gr)
2323 {
2324 	mglData a;	mgls_prepare2d(&a);
2325 	gr->Light(true);
2326 	gr->SubPlot(2,1,0);	gr->Rotate(50,60+1);
2327 	gr->Box();	gr->Surf(a);
2328 	gr->SubPlot(2,1,1);	gr->Rotate(50,60-1);
2329 	gr->Box();	gr->Surf(a);
2330 }
2331 //-----------------------------------------------------------------------------
2332 const char *mmgl_hist="new x 10000 '2*rnd-1':new y 10000 '2*rnd-1':copy z exp(-6*(x^2+y^2))\n"
2333 "hist xx x z:norm xx 0 1:hist yy y z:norm yy 0 1\nmultiplot 3 3 3 2 2 '':ranges -1 1 -1 1 0 1:box:dots x y z 'wyrRk'\n"
2334 "multiplot 3 3 0 2 1 '':ranges -1 1 0 1:box:bars xx\nmultiplot 3 3 5 1 2 '':ranges 0 1 -1 1:box:barh yy\n"
2335 "subplot 3 3 2:text 0.5 0.5 'Hist and\\n{}MultiPlot\\n{}sample' 'a' -3";
smgl_hist(mglGraph * gr)2336 void smgl_hist(mglGraph *gr)
2337 {
2338 	mglData x(10000), y(10000), z(10000);	gr->Fill(x,"2*rnd-1");	gr->Fill(y,"2*rnd-1");	gr->Fill(z,"exp(-6*(v^2+w^2))",x,y);
2339 	mglData xx=gr->Hist(x,z), yy=gr->Hist(y,z);	xx.Norm(0,1);	yy.Norm(0,1);
2340 	gr->MultiPlot(3,3,3,2,2,"");	gr->SetRanges(-1,1,-1,1,0,1);	gr->Box();	gr->Dots(x,y,z,"wyrRk");
2341 	gr->MultiPlot(3,3,0,2,1,"");	gr->SetRanges(-1,1,0,1);	gr->Box();	gr->Bars(xx);
2342 	gr->MultiPlot(3,3,5,1,2,"");	gr->SetRanges(0,1,-1,1);	gr->Box();	gr->Barh(yy);
2343 	gr->SubPlot(3,3,2);		gr->Puts(mglPoint(0.5,0.5),"Hist and\nMultiPlot\nsample","a",-3);
2344 }
2345 //-----------------------------------------------------------------------------
2346 const char *mmgl_primitives="subplot 2 2 0 '':title 'Line, Curve, Rhomb, Ellipse' '' -1.5\n"
2347 "line -1 -1 -0.5 1 'qAI'\ncurve -0.6 -1 1 1 0 1 1 1 'rA'\nball 0 -0.5 '*':ball 1 -0.1 '*'\n"
2348 "rhomb 0 0.4 1 0.9 0.2 'b#'\nrhomb 0 0 1 0.4 0.2 'cg@'\n"
2349 "ellipse 0 -0.5 1 -0.1 0.2 'u#'\nellipse 0 -1 1 -0.6 0.2 'm@'\n\n"
2350 "subplot 2 3 1 '':title 'Arc, Polygon, Symbol';size -1.2\n"
2351 "arc -0.6 0 -0.6 0.3 180 '2kA':ball -0.6 0\npolygon 0 0 0 0.4 6 'r'\n"
2352 "new x 50 'cos(3*pi*x)':new y 50 'sin(pi*x)'\n"
2353 "addsymbol 'a' x y\nsymbol 0.7 0 'a'\n\n"
2354 "light on\nsubplot 2 3 3 '<^>' 0 -0.2:title 'Face[xyz]';size -1.5:rotate 50 60:box\n"
2355 "facex 1 0 -1 1 1 'r':facey -1 -1 -1 1 1 'g':facez 1 -1 -1 -1 1 'b'\n"
2356 "face -1 -1 1 -1 1 1 1 -1 0 1 1 1 'bmgr'\n\n"
2357 "subplot 2 3 5 '':title 'Cone';size -1.5\n"
2358 "cone -0.7 -0.3 0 -0.7 0.7 0.5 0.2 0.1 'b':text -0.7 -0.7 'no edges\\n(default)';size -1.5\n"
2359 "cone 0 -0.3 0 0 0.7 0.5 0.2 0.1 'g@':text 0 -0.7 'with edges\\n(\"\\@\" style)';size -1.5\n"
2360 "cone 0.7 -0.3 0 0.7 0.7 0.5 0.2 0 'Ggb':text 0.7 -0.7 '\"arrow\" with\\n{}gradient';size -1.5\n"
2361 "subplot 2 2 2 '':title 'Sphere and Drop'\nline -0.9 0 1 0.9 0 1\n"
2362 "text -0.9 0.4 'sh=0':drop -0.9 0 0 1 0.5 'r' 0:ball -0.9 0 1 'k'\n"
2363 "text -0.3 0.6 'sh=0.33':drop -0.3 0 0 1 0.5 'r' 0.33:ball -0.3 0 1 'k'\n"
2364 "text 0.3 0.8 'sh=0.67':drop 0.3 0 0 1 0.5 'r' 0.67:ball 0.3 0 1 'k'\n"
2365 "text 0.9 1. 'sh=1':drop 0.9 0 0 1 0.5 'r' 1:ball 0.9 0 1 'k'\n\n"
2366 "text -0.9 -1.1 'asp=0.33':drop -0.9 -0.7 0 1 0.5 'b' 0 0.33\n"
2367 "text -0.3 -1.1 'asp=0.67':drop -0.3 -0.7 0 1 0.5 'b' 0 0.67\n"
2368 "text 0.3 -1.1 'asp=1':drop 0.3 -0.7 0 1 0.5 'b' 0 1\n"
2369 "text 0.9 -1.1 'asp=1.5':drop 0.9 -0.7 0 1 0.5 'b' 0 1.5";
smgl_primitives(mglGraph * gr)2370 void smgl_primitives(mglGraph *gr)	// flag #
2371 {
2372 	gr->SubPlot(2,2,0,"");	gr->Title("Line, Curve, Rhomb, Ellipse","",-1.5);
2373 	gr->Line(mglPoint(-1,-1),mglPoint(-0.5,1),"qAI");
2374 	gr->Curve(mglPoint(-0.6,-1),mglPoint(1,1),mglPoint(0,1),mglPoint(1,1),"rA");
2375 	gr->Rhomb(mglPoint(0,0.4),mglPoint(1,0.9),0.2,"b#");
2376 	gr->Rhomb(mglPoint(0,0),mglPoint(1,0.4),0.2,"cg@");
2377 	gr->Ellipse(mglPoint(0,-0.5),mglPoint(1,-0.1),0.2,"u#");
2378 	gr->Ellipse(mglPoint(0,-1),mglPoint(1,-0.6),0.2,"m@");
2379 	gr->Mark(mglPoint(0,-0.5),"*");	gr->Mark(mglPoint(1,-0.1),"*");
2380 
2381 	gr->SubPlot(2,3,1,"");	gr->Title("Arc, Polygon, Symbol","", -1.2*2);
2382 	gr->Arc(mglPoint(-0.6,0), mglPoint(-0.6,0.3), 180, "2kA");	gr->Ball(-0.6,0);
2383 	gr->Polygon(mglPoint(), mglPoint(0,0.4), 6, "r");
2384 	mglData x(50), y(50);	gr->Fill(x,"cos(3*pi*x)");	gr->Fill(y,"sin(pi*x)");
2385 	gr->DefineSymbol('a',x,y);	gr->Symbol(mglPoint(0.7),'a');
2386 
2387 	gr->Light(true);
2388 	gr->SubPlot(2,3,3,"<^>",0,-0.2);	gr->Title("Face[xyz]", "", -1.5*2);
2389 	gr->Rotate(50,60);	gr->Box();
2390 	gr->FaceX(mglPoint(1,0,-1),1,1,"r");
2391 	gr->FaceY(mglPoint(-1,-1,-1),1,1,"g");
2392 	gr->FaceZ(mglPoint(1,-1,-1),-1,1,"b");
2393 	gr->Face(mglPoint(-1,-1,1),mglPoint(-1,1,1),mglPoint(1,-1,0),mglPoint(1,1,1),"bmgr");
2394 
2395 	gr->SubPlot(2,3,5,"");	gr->Title("Cone", "", -1.5*2);
2396 	gr->Cone(mglPoint(-0.7,-0.3),mglPoint(-0.7,0.7,0.5),0.2,0.1,"b");
2397 	gr->Puts(mglPoint(-0.7,-0.7),"no edges\n(default)","", -1.5);
2398 	gr->Cone(mglPoint(0,-0.3),mglPoint(0,0.7,0.5),0.2,0.1,"g@");
2399 	gr->Puts(mglPoint(0,-0.7),"with edges\n('\\@' style)","", -1.5);
2400 	gr->Cone(mglPoint(0.7,-0.3),mglPoint(0.7,0.7,0.5),0.2,0,"ry");
2401 	gr->Puts(mglPoint(0.7,-0.7),"'arrow' with\ngradient","", -1.5);
2402 
2403 	gr->SubPlot(2,2,2,"");	gr->Title("Sphere and Drop");	gr->Alpha(false);
2404 	gr->Puts(mglPoint(-0.9,0.4),"sh=0");		gr->Ball(mglPoint(-0.9,0,1),'k');
2405 	gr->Drop(mglPoint(-0.9,0),mglPoint(0,1),0.5,"r",0);
2406 	gr->Puts(mglPoint(-0.3,0.6),"sh=0.33");	gr->Ball(mglPoint(-0.3,0,1),'k');
2407 	gr->Drop(mglPoint(-0.3,0),mglPoint(0,1),0.5,"r",0.33);
2408 	gr->Puts(mglPoint(0.3,0.8),"sh=0.67");		gr->Ball(mglPoint(0.3,0,1),'k');
2409 	gr->Drop(mglPoint(0.3,0),mglPoint(0,1),0.5,"r",0.67);
2410 	gr->Puts(mglPoint(0.9,1),"sh=1");			gr->Ball(mglPoint(0.9,0,1),'k');
2411 	gr->Drop(mglPoint(0.9,0),mglPoint(0,1),0.5,"r",1);
2412 	gr->Line(mglPoint(-0.9,0,1),mglPoint(0.9,0,1),"b");
2413 
2414 	gr->Puts(mglPoint(-0.9,-1.1),"asp=0.33");
2415 	gr->Drop(mglPoint(-0.9,-0.7),mglPoint(0,1),0.5,"b",0,0.33);
2416 	gr->Puts(mglPoint(-0.3,-1.1),"asp=0.67");
2417 	gr->Drop(mglPoint(-0.3,-0.7),mglPoint(0,1),0.5,"b",0,0.67);
2418 	gr->Puts(mglPoint(0.3,-1.1),"asp=1");
2419 	gr->Drop(mglPoint(0.3,-0.7),mglPoint(0,1),0.5,"b",0,1);
2420 	gr->Puts(mglPoint(0.9,-1.1),"asp=1.5");
2421 	gr->Drop(mglPoint(0.9,-0.7),mglPoint(0,1),0.5,"b",0,1.5);
2422 }
2423 //-----------------------------------------------------------------------------
2424 const char *mmgl_table="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd'\n"
2425 "subplot 2 2 0:title 'Table sample':box\ntable ys 'y_1\\n{}y_2\\n{}y_3'\n\n"
2426 "subplot 2 2 1:title 'no borders, colored'\ntable ys 'y_1\\n{}y_2\\n{}y_3' 'r|'\n\n"
2427 "subplot 2 2 2:title 'no font decrease'\ntable ys 'y_1\\n{}y_2\\n{}y_3' '#'\n\n"
2428 "subplot 2 2 3:title 'manual width and position':box\n"
2429 "table 0.5 0.95 ys 'y_1\\n{}y_2\\n{}y_3' '#';value 0.7";
smgl_table(mglGraph * gr)2430 void smgl_table(mglGraph *gr)
2431 {
2432 	mglData ys(10,3);	ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
2433 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Table plot");	}
2434 	gr->Table(ys,"y_1\ny_2\ny_3");	gr->Box();
2435 	if(big==3)	return;
2436 	gr->SubPlot(2,2,1);	gr->Title("no borders, colored");
2437 	gr->Table(ys,"y_1\ny_2\ny_3","r|");
2438 	gr->SubPlot(2,2,2);	gr->Title("no font decrease");
2439 	gr->Table(ys,"y_1\ny_2\ny_3","#");
2440 	gr->SubPlot(2,2,3);	gr->Title("manual width, position");
2441 	gr->Table(0.5, 0.95, ys,"y_1\ny_2\ny_3","#", "value 0.7");	gr->Box();
2442 }
2443 //-----------------------------------------------------------------------------
2444 const char *mmgl_label="new ys 10 '0.2*rnd-0.8*sin(pi*x)'\n"
2445 "subplot 1 1 0 '':title 'Label plot':box:plot ys ' *':label ys 'y=%y'";
smgl_label(mglGraph * gr)2446 void smgl_label(mglGraph *gr)
2447 {
2448 	mglData ys(10);	ys.Modify("0.8*sin(pi*2*x)+0.2*rnd");
2449 	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("Label plot");	}
2450 	gr->Box();	gr->Plot(ys," *");	gr->Label(ys,"y=%y");
2451 }
2452 //-----------------------------------------------------------------------------
2453 const char *mmgl_colorbar="call 'prepare2d'\nnew v 9 'x'\nsubplot 2 2 0:title 'Colorbar out of box':box\n"
2454 "colorbar '<':colorbar '>':colorbar '_':colorbar '^'\n"
2455 "subplot 2 2 1:title 'Colorbar near box':box\n"
2456 "colorbar '<I':colorbar '>I':colorbar '_I':colorbar '^I'\n"
2457 "subplot 2 2 2:title 'manual colors':box:contd v a\n"
2458 "colorbar v '<':colorbar v '>':colorbar v '_':colorbar v '^'\n"
2459 "subplot 2 2 3:title '':text -0.5 1.55 'Color positions' ':C' -2\n"
2460 "colorbar 'bwr>' 0.25 0:text -0.9 1.2 'Default'\n"
2461 "colorbar 'b{w,0.3}r>' 0.5 0:text -0.1 1.2 'Manual'\ncrange 0.01 1e3\n"
2462 "colorbar '>' 0.75 0:text 0.65 1.2 'Normal scale':colorbar '>':text 1.35 1.2 'Log scale'";
smgl_colorbar(mglGraph * gr)2463 void smgl_colorbar(mglGraph *gr)
2464 {
2465 	gr->SubPlot(2,2,0);	gr->Title("Colorbar out of box");	gr->Box();
2466 	gr->Colorbar("<");	gr->Colorbar(">");	gr->Colorbar("_");	gr->Colorbar("^");
2467 	gr->SubPlot(2,2,1);	gr->Title("Colorbar near box");		gr->Box();
2468 	gr->Colorbar("<I");	gr->Colorbar(">I");	gr->Colorbar("_I");	gr->Colorbar("^I");
2469 	gr->SubPlot(2,2,2);	gr->Title("manual colors");
2470 	mglData a,v;	mgls_prepare2d(&a,0,&v);
2471 	gr->Box();	gr->ContD(v,a);
2472 	gr->Colorbar(v,"<");	gr->Colorbar(v,">");	gr->Colorbar(v,"_");	gr->Colorbar(v,"^");
2473 
2474 	gr->SubPlot(2,2,3);	gr->Title(" ");
2475 	gr->Puts(mglPoint(-0.5,1.55),"Color positions",":C",-2);
2476 	gr->Colorbar("bwr>",0.25,0);	gr->Puts(mglPoint(-0.9,1.2),"Default");
2477 	gr->Colorbar("b{w,0.3}r>",0.5,0);	gr->Puts(mglPoint(-0.1,1.2),"Manual");
2478 
2479 	gr->Puts(mglPoint(1,1.55),"log-scale",":C",-2);
2480 	gr->SetRange('c',0.01,1e3);
2481 	gr->Colorbar(">",0.75,0);	gr->Puts(mglPoint(0.65,1.2),"Normal scale");
2482 	gr->SetFunc("","","","lg(c)");
2483 	gr->Colorbar(">");		gr->Puts(mglPoint(1.35,1.2),"Log scale");
2484 }
2485 //-----------------------------------------------------------------------------
2486 const char *mmgl_legend="addlegend 'sin(\\pi {x^2})' 'b':addlegend 'sin(\\pi x)' 'g*'\n"
2487 "addlegend 'sin(\\pi \\sqrt{x})' 'rd':addlegend 'jsut text' ' ':addlegend 'no indent for this' ''\n"
2488 "subplot 2 2 0 '':title 'Legend (default)':box:legend\n"
2489 "legend 1 0.5 '^':text 0.49 0.88 'Style \"\\^\"' 'A:L'\n"
2490 "legend 3 'A#':text 0.75 0.65 'Absolute position' 'A'\n"
2491 "subplot 2 2 2 '':title 'coloring':box:legend 0 'r#':legend 1 'Wb#':legend 2 'ygr#'\n"
2492 "subplot 2 2 3 '':title 'manual position':box\n"
2493 "legend 0.5 1:text 0.5 0.5 'at x=0.5, y=1' 'a'\n"
2494 "legend 1 '#-':text 0.75 0.25 'Horizontal legend' 'a'";
smgl_legend(mglGraph * gr)2495 void smgl_legend(mglGraph *gr)
2496 {
2497 	gr->AddLegend("sin(\\pi {x^2})","b");
2498 	gr->AddLegend("sin(\\pi x)","g*");
2499 	gr->AddLegend("sin(\\pi \\sqrt{x})","rd");
2500 	gr->AddLegend("just text"," ");
2501 	gr->AddLegend("no indent for this","");
2502 	if(big!=3)	{gr->SubPlot(2,2,0,"");	gr->Title("Legend (default)");}
2503 	gr->Box();	gr->Legend();
2504 	if(big==3)	return;
2505 	gr->Legend(1,0.5,"^");	gr->Puts(0.49, 0.88, "Style '\\^'","A:L");
2506 	gr->Legend(3,"A#");
2507 	gr->Puts(mglPoint(0.75,0.65),"Absolute position","A");
2508 	gr->SubPlot(2,2,2,"");	gr->Title("coloring");	gr->Box();
2509 	gr->Legend(0,"r#");	gr->Legend(1,"Wb#");	gr->Legend(2,"ygr#");
2510 	gr->SubPlot(2,2,3,"");	gr->Title("manual position");	gr->Box();
2511 	gr->Legend(0.5,1);
2512 	gr->Puts(mglPoint(0.5,0.5),"at x=0.5, y=1","a");
2513 	gr->Legend(1,"#-");
2514 	gr->Puts(mglPoint(0.75,0.25),"Horizontal legend","a");
2515 }
2516 //-----------------------------------------------------------------------------
2517 const char *mmgl_dat_diff="ranges 0 1 0 1 0 1:new a 30 40 'x*y'\n"
2518 "subplot 2 2 0:title 'a(x,y)':rotate 60 40:surf a:box\n"
2519 "subplot 2 2 1:title 'da/dx':rotate 60 40:diff a 'x':surf a:box\n"
2520 "subplot 2 2 2:title '\\int da/dx dxdy':rotate 60 40:integrate a 'xy':surf a:box\n"
2521 "subplot 2 2 3:title '\\int {d^2}a/dxdy dx':rotate 60 40:diff2 a 'y':surf a:box";
smgl_dat_diff(mglGraph * gr)2522 void smgl_dat_diff(mglGraph *gr)	// differentiate
2523 {
2524 	gr->SetRanges(0,1,0,1,0,1);
2525 	mglData a(30,40);	a.Modify("x*y");
2526 	gr->SubPlot(2,2,0);	gr->Title("a(x,y)");	gr->Rotate(60,40);
2527 	gr->Surf(a);		gr->Box();
2528 	gr->SubPlot(2,2,1);	gr->Title("da/dx");		gr->Rotate(60,40);
2529 	a.Diff("x");		gr->Surf(a);	gr->Box();
2530 	gr->SubPlot(2,2,2);	gr->Title("\\int da/dx dxdy");	gr->Rotate(60,40);
2531 	a.Integral("xy");	gr->Surf(a);	gr->Box();
2532 	gr->SubPlot(2,2,3);	gr->Title("\\int {d^2}a/dxdy dx");	gr->Rotate(60,40);
2533 	a.Diff2("y");	gr->Surf(a);	gr->Box();
2534 }
2535 //-----------------------------------------------------------------------------
2536 const char *mmgl_dat_extra="subplot 2 2 0 '':title 'Envelop sample':new d1 1000 'exp(-8*x^2)*sin(10*pi*x)'\n"
2537 "axis:plot d1 'b':envelop d1 'x':plot d1 'r'\n"
2538 "subplot 2 2 1 '':title 'Smooth sample':ranges 0 1 0 1\nnew y0 30 '0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd'\n"
2539 "copy y1 y0:smooth y1 'x3':plot y1 'r';legend '\"3\" style'\ncopy y2 y0:smooth y2 'x5':plot y2 'g';legend '\"5\" style'\n"
2540 "copy y3 y0:smooth y3 'x':plot y3 'b';legend 'default'\nplot y0 '{m7}:s';legend 'none'\nlegend:box\n"
2541 "subplot 2 2 2:title 'Sew sample':rotate 50 60:light on:alpha on\nnew d2 100 100 'mod((y^2-(1-x)^2)/2,0.1)'\n"
2542 "box:surf d2 'b':sew d2 'xy' 0.1:surf d2 'r'\n"
2543 "subplot 2 2 3:title 'Resize sample (interpolation)'\nnew x0 10 'rnd':new v0 10 'rnd'\n"
2544 "resize x1 x0 100:resize v1 v0 100\nplot x0 v0 'b+ ':plot x1 v1 'r-':label x0 v0 '%n'";
smgl_dat_extra(mglGraph * gr)2545 void smgl_dat_extra(mglGraph *gr)	// differentiate
2546 {
2547 	gr->SubPlot(2,2,0,"");	gr->Title("Envelop sample");
2548 	mglData d1(1000);	gr->Fill(d1,"exp(-8*x^2)*sin(10*pi*x)");
2549 	gr->Axis();			gr->Plot(d1, "b");
2550 	d1.Envelop('x');	gr->Plot(d1, "r");
2551 
2552 	gr->SubPlot(2,2,1,"");	gr->Title("Smooth sample");
2553 	mglData y0(30),y1,y2,y3;
2554 	gr->SetRanges(0,1,0,1);
2555 	gr->Fill(y0, "0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd");
2556 
2557 	y1=y0;	y1.Smooth("x3");
2558 	y2=y0;	y2.Smooth("x5");
2559 	y3=y0;	y3.Smooth("x");
2560 
2561 	gr->Plot(y0,"{m7}:s", "legend 'none'");	//gr->AddLegend("none","k");
2562 	gr->Plot(y1,"r", "legend ''3' style'");
2563 	gr->Plot(y2,"g", "legend ''5' style'");
2564 	gr->Plot(y3,"b", "legend 'default'");
2565 	gr->Legend();		gr->Box();
2566 
2567 	gr->SubPlot(2,2,2);		gr->Title("Sew sample");
2568 	mglData d2(100, 100);	gr->Fill(d2, "mod((y^2-(1-x)^2)/2,0.1)");
2569 	gr->Rotate(50, 60);	gr->Light(true);	gr->Alpha(true);
2570 	gr->Box();			gr->Surf(d2, "b");
2571 	d2.Sew("xy", 0.1);	gr->Surf(d2, "r");
2572 
2573 	gr->SubPlot(2,2,3);		gr->Title("Resize sample (interpolation)");
2574 	mglData x0(10), v0(10), x1, v1;
2575 	gr->Fill(x0,"rnd");		gr->Fill(v0,"rnd");
2576 	x1 = x0.Resize(100);	v1 = v0.Resize(100);
2577 	gr->Plot(x0,v0,"b+ ");	gr->Plot(x1,v1,"r-");
2578 	gr->Label(x0,v0,"%n");
2579 }
2580 //-----------------------------------------------------------------------------
2581 const char *mmgl_ternary="ranges 0 1 0 1 0 1\nnew x 50 '0.25*(1+cos(2*pi*x))'\n"
2582 "new y 50 '0.25*(1+sin(2*pi*x))'\nnew z 50 'x'\nnew a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'\n"
2583 "new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx\nlight on\n\n"
2584 "subplot 2 2 0:title 'Ordinary axis 3D':rotate 50 60\nbox:axis:grid\n"
2585 "plot x y z 'r2':surf a '#'\nxlabel 'B':ylabel 'C':zlabel 'Z'\n\n"
2586 "subplot 2 2 1:title 'Ternary axis (x+y+t=1)':ternary 1\nbox:axis:grid 'xyz' 'B;'\n"
2587 "plot x y 'r2':plot rx ry 'q^ ':cont a:line 0.5 0 0 0.75 'g2'\nxlabel 'B':ylabel 'C':tlabel 'A'\n\n"
2588 "subplot 2 2 2:title 'Quaternary axis 3D':rotate 50 60:ternary 2\nbox:axis:grid 'xyz' 'B;'\n"
2589 "plot x y z 'r2':surf a '#'\nxlabel 'B':ylabel 'C':tlabel 'A':zlabel 'D'\n\n"
2590 "subplot 2 2 3:title 'Ternary axis 3D':rotate 50 60:ternary 1\nbox:axis:grid 'xyz' 'B;'\n"
2591 "plot x y z 'r2':surf a '#'\nxlabel 'B':ylabel 'C':tlabel 'A':zlabel 'Z'";
smgl_ternary(mglGraph * gr)2592 void smgl_ternary(mglGraph *gr)	// flag #
2593 {
2594 	gr->SetRanges(0,1,0,1,0,1);
2595 	mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30);
2596 	a.Modify("30*x*y*(1-x-y)^2*(x+y<1)");
2597 	x.Modify("0.25*(1+cos(2*pi*x))");
2598 	y.Modify("0.25*(1+sin(2*pi*x))");
2599 	rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx);
2600 	z.Modify("x");
2601 
2602 	gr->SubPlot(2,2,0);	gr->Title("Ordinary axis 3D");
2603 	gr->Rotate(50,60);		gr->Light(true);
2604 	gr->Plot(x,y,z,"r2");	gr->Surf(a,"BbcyrR#");
2605 	gr->Axis(); gr->Grid();	gr->Box();
2606 	gr->Label('x',"B",1);	gr->Label('y',"C",1);	gr->Label('z',"Z",1);
2607 
2608 	gr->SubPlot(2,2,1);	gr->Title("Ternary axis (x+y+t=1)");
2609 	gr->Ternary(1);
2610 	gr->Plot(x,y,"r2");	gr->Plot(rx,ry,"q^ ");	gr->Cont(a);
2611 	gr->Line(mglPoint(0.5,0), mglPoint(0,0.75), "g2");
2612 	gr->Axis(); gr->Grid("xyz","B;");
2613 	gr->Label('x',"B");	gr->Label('y',"C");	gr->Label('t',"A");
2614 
2615 	gr->SubPlot(2,2,2);	gr->Title("Quaternary axis 3D");
2616 	gr->Rotate(50,60);		gr->Light(true);
2617 	gr->Ternary(2);
2618 	gr->Plot(x,y,z,"r2");	gr->Surf(a,"BbcyrR#");
2619 	gr->Axis(); gr->Grid();	gr->Box();
2620 	gr->Label('t',"A",1);	gr->Label('x',"B",1);
2621 	gr->Label('y',"C",1);	gr->Label('z',"D",1);
2622 
2623 	gr->SubPlot(2,2,3);	gr->Title("Ternary axis 3D");
2624 	gr->Rotate(50,60);		gr->Light(true);
2625 	gr->Ternary(1);
2626 	gr->Plot(x,y,z,"r2");	gr->Surf(a,"BbcyrR#");
2627 	gr->Axis(); gr->Grid();	gr->Box();
2628 	gr->Label('t',"A",1);	gr->Label('x',"B",1);
2629 	gr->Label('y',"C",1);	gr->Label('z',"Z",1);
2630 }
2631 //-----------------------------------------------------------------------------
2632 const char *mmgl_projection="ranges 0 1 0 1 0 1\nnew x 50 '0.25*(1+cos(2*pi*x))'\n"
2633 "new y 50 '0.25*(1+sin(2*pi*x))'\nnew z 50 'x'\nnew a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'\n"
2634 "new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx\nlight on\n\n"
2635 "title 'Projection sample':ternary 4:rotate 50 60\nbox:axis:grid\n"
2636 "plot x y z 'r2':surf a '#'\nxlabel 'X':ylabel 'Y':zlabel 'Z'";
smgl_projection(mglGraph * gr)2637 void smgl_projection(mglGraph *gr)	// flag #
2638 {
2639 	gr->SetRanges(0,1,0,1,0,1);
2640 	mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30);
2641 	a.Modify("30*x*y*(1-x-y)^2*(x+y<1)");
2642 	x.Modify("0.25*(1+cos(2*pi*x))");
2643 	y.Modify("0.25*(1+sin(2*pi*x))");
2644 	rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx);
2645 	z.Modify("x");
2646 
2647 	if(big!=3)	gr->Title("Projection sample");
2648 	gr->Ternary(4);
2649 	gr->Rotate(50,60);		gr->Light(true);
2650 	gr->Plot(x,y,z,"r2");	gr->Surf(a,"#");
2651 	gr->Axis(); gr->Grid();	gr->Box();
2652 	gr->Label('x',"X",1);	gr->Label('y',"Y",1);	gr->Label('z',"Z",1);
2653 }
2654 //-----------------------------------------------------------------------------
2655 const char *mmgl_projection5="ranges 0 1 0 1 0 1\nnew x 50 '0.25*(1+cos(2*pi*x))'\n"
2656 "new y 50 '0.25*(1+sin(2*pi*x))'\nnew z 50 'x'\nnew a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'\n"
2657 "new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx\nlight on\n\n"
2658 "title 'Projection sample (ternary)':ternary 5:rotate 50 60\nbox:axis:grid\n"
2659 "plot x y z 'r2':surf a '#'\nxlabel 'X':ylabel 'Y':zlabel 'Z'";
smgl_projection5(mglGraph * gr)2660 void smgl_projection5(mglGraph *gr)	// flag #
2661 {
2662 	gr->SetRanges(0,1,0,1,0,1);
2663 	mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30);
2664 	a.Modify("30*x*y*(1-x-y)^2*(x+y<1)");
2665 	x.Modify("0.25*(1+cos(2*pi*x))");
2666 	y.Modify("0.25*(1+sin(2*pi*x))");
2667 	rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx);
2668 	z.Modify("x");
2669 
2670 	if(big!=3)	gr->Title("Projection sample (ternary)");
2671 	gr->Ternary(5);
2672 	gr->Rotate(50,60);		gr->Light(true);
2673 	gr->Plot(x,y,z,"r2");	gr->Surf(a,"#");
2674 	gr->Axis(); gr->Grid();	gr->Box();
2675 	gr->Label('x',"X",1);	gr->Label('y',"Y",1);	gr->Label('z',"Z",1);
2676 }
2677 //-----------------------------------------------------------------------------
2678 const char *mmgl_triplot="list q 0 1 2 3 | 4 5 6 7 | 0 2 4 6 | 1 3 5 7 | 0 4 1 5 | 2 6 3 7\n"
2679 "list xq -1 1 -1 1 -1 1 -1 1\nlist yq -1 -1 1 1 -1 -1 1 1\nlist zq -1 -1 -1 -1 1 1 1 1\nlight on\n"
2680 "subplot 2 2 0:title 'QuadPlot sample':rotate 50 60\n"
2681 "quadplot q xq yq zq 'yr'\nquadplot q xq yq zq '#k'\n"
2682 "subplot 2 2 2:title 'QuadPlot coloring':rotate 50 60\n"
2683 "quadplot q xq yq zq yq 'yr'\nquadplot q xq yq zq '#k'\n"
2684 "list t 0 1 2 | 0 1 3 | 0 2 3 | 1 2 3\n"
2685 "list xt -1 1 0 0\nlist yt -1 -1 1 0\nlist zt -1 -1 -1 1\n"
2686 "subplot 2 2 1:title 'TriPlot sample':rotate 50 60\n"
2687 "triplot t xt yt zt 'b'\ntriplot t xt yt zt '#k'\n"
2688 "subplot 2 2 3:title 'TriPlot coloring':rotate 50 60\n"
2689 "triplot t xt yt zt yt 'cb'\ntriplot t xt yt zt '#k'\ntricont t xt yt zt 'B'";
smgl_triplot(mglGraph * gr)2690 void smgl_triplot(mglGraph *gr)
2691 {
2692 	double q[] = {0,1,2,3, 4,5,6,7, 0,2,4,6, 1,3,5,7, 0,4,1,5, 2,6,3,7};
2693 	double xc[] = {-1,1,-1,1,-1,1,-1,1}, yc[] = {-1,-1,1,1,-1,-1,1,1}, zc[] = {-1,-1,-1,-1,1,1,1,1};
2694 	mglData qq(6,4,q), xx(8,xc), yy(8,yc), zz(8,zc);
2695 	gr->Light(true);	//gr->Alpha(true);
2696 	gr->SubPlot(2,2,0);	gr->Title("QuadPlot sample");	gr->Rotate(50,60);
2697 	gr->QuadPlot(qq,xx,yy,zz,"yr");
2698 	gr->QuadPlot(qq,xx,yy,zz,"k#");
2699 	gr->SubPlot(2,2,2);	gr->Title("QuadPlot coloring");	gr->Rotate(50,60);
2700 	gr->QuadPlot(qq,xx,yy,zz,yy,"yr");
2701 	gr->QuadPlot(qq,xx,yy,zz,"k#");
2702 
2703 	double t[] = {0,1,2, 0,1,3, 0,2,3, 1,2,3};
2704 	double xt[] = {-1,1,0,0}, yt[] = {-1,-1,1,0}, zt[] = {-1,-1,-1,1};
2705 	mglData tt(4,3,t), uu(4,xt), vv(4,yt), ww(4,zt);
2706 	gr->SubPlot(2,2,1);	gr->Title("TriPlot sample");	gr->Rotate(50,60);
2707 	gr->TriPlot(tt,uu,vv,ww,"b");
2708 	gr->TriPlot(tt,uu,vv,ww,"k#");
2709 	gr->SubPlot(2,2,3);	gr->Title("TriPlot coloring");	gr->Rotate(50,60);
2710 	gr->TriPlot(tt,uu,vv,ww,vv,"cb");
2711 	gr->TriPlot(tt,uu,vv,ww,"k#");
2712 	gr->TriCont(tt,uu,vv,ww,"B");
2713 }
2714 //-----------------------------------------------------------------------------
2715 const char *mmgl_dots="new t 2000 'pi*(rnd-0.5)':new f 2000 '2*pi*rnd'\n"
2716 "copy x 0.9*cos(t)*cos(f):copy y 0.9*cos(t)*sin(f):copy z 0.6*sin(t):copy c cos(2*t)\n"
2717 "subplot 2 2 0:title 'Dots sample':rotate 50 60\nbox:dots x y z\nalpha on\n"
2718 "subplot 2 2 1:title 'add transparency':rotate 50 60\nbox:dots x y z c\n"
2719 "subplot 2 2 2:title 'add colorings':rotate 50 60\nbox:dots x y z x c\n"
2720 "subplot 2 2 3:title 'Only coloring':rotate 50 60\nbox:tens x y z x ' .'";
smgl_dots(mglGraph * gr)2721 void smgl_dots(mglGraph *gr)
2722 {
2723 	int i, n=1000;
2724 	mglData x(n),y(n),z(n),c(n);
2725 	for(i=0;i<n;i++)
2726 	{
2727 		double t=M_PI*(mgl_rnd()-0.5), f=2*M_PI*mgl_rnd();
2728 		x.a[i] = 0.9*cos(t)*cos(f);
2729 		y.a[i] = 0.9*cos(t)*sin(f);
2730 		z.a[i] = 0.6*sin(t);
2731 		c.a[i] = cos(2*t);
2732 	}
2733 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Dots sample");	}
2734 	gr->Rotate(50,60);	gr->Box();	gr->Dots(x,y,z);
2735 	if(big==3)	return;
2736 	gr->Alpha(true);
2737 	gr->SubPlot(2,2,1);	gr->Title("add transparency");		gr->Rotate(50,60);	gr->Box();	gr->Dots(x,y,z,c);
2738 	gr->SubPlot(2,2,2);	gr->Title("add coloring");	gr->Rotate(50,60);	gr->Box();	gr->Dots(x,y,z,x,c);
2739 	gr->SubPlot(2,2,3);	gr->Title("Only coloring");		gr->Rotate(50,60);	gr->Box();	gr->Tens(x,y,z,x," .");
2740 }
2741 //-----------------------------------------------------------------------------
2742 /*void smgl_surf3_rgbd(mglGraph *gr)
2743 {
2744 	mglData c;	mgls_prepare3d(&c);
2745 	gr->Rotate(40,60);	gr->VertexColor(true);
2746 	gr->Box();	gr->Surf3(c,"bgrd");
2747 }*/
2748 //-----------------------------------------------------------------------------
2749 const char *mmgl_mirror="new a 31 41 '-pi*x*exp(-(y+1)^2-4*x^2)'\n"
2750 "subplot 2 2 0:title 'Options for coordinates':alpha on:light on:rotate 40 60:box\n"
2751 "surf a 'r';yrange 0 1:surf a 'b';yrange 0 -1\n"
2752 "subplot 2 2 1:title 'Option \"meshnum\"':rotate 40 60:box\n"
2753 "mesh a 'r'; yrange 0 1:mesh a 'b';yrange 0 -1; meshnum 5\n"
2754 "subplot 2 2 2:title 'Option \"alpha\"':rotate 40 60:box\n"
2755 "surf a 'r';yrange 0 1; alpha 0.7:surf a 'b';yrange 0 -1; alpha 0.3\n"
2756 "subplot 2 2 3 '<_':title 'Option \"legend\"'\n"
2757 "fplot 'x^3' 'r'; legend 'y = x^3':fplot 'cos(pi*x)' 'b'; legend 'y = cos \\pi x'\n"
2758 "box:axis:legend 2";
smgl_mirror(mglGraph * gr)2759 void smgl_mirror(mglGraph *gr)	// flag #
2760 {
2761 	mglData a(31,41);
2762 	gr->Fill(a,"-pi*x*exp(-(y+1)^2-4*x^2)");
2763 
2764 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Options for coordinates");	}
2765 	gr->Alpha(true);	gr->Light(true);
2766 	gr->Rotate(40,60);	gr->Box();
2767 	gr->Surf(a,"r","yrange 0 1"); gr->Surf(a,"b","yrange 0 -1");
2768 	if(big==3)	return;
2769 	gr->SubPlot(2,2,1);	gr->Title("Option 'meshnum'");
2770 	gr->Rotate(40,60);	gr->Box();
2771 	gr->Mesh(a,"r","yrange 0 1"); gr->Mesh(a,"b","yrange 0 -1; meshnum 5");
2772 	gr->SubPlot(2,2,2);	gr->Title("Option 'alpha'");
2773 	gr->Rotate(40,60);	gr->Box();
2774 	gr->Surf(a,"r","yrange 0 1; alpha 0.7"); gr->Surf(a,"b","yrange 0 -1; alpha 0.3");
2775 	gr->SubPlot(2,2,3,"<_");	gr->Title("Option 'legend'");
2776 	gr->FPlot("x^3","r","legend 'y = x^3'"); gr->FPlot("cos(pi*x)","b","legend 'y = cos \\pi x'");
2777 	gr->Box();	gr->Axis();	gr->Legend(2,"");
2778 }
2779 //-----------------------------------------------------------------------------
2780 const char *mmgl_pulse="subplot 1 1 0 '<_':title 'Pulse sample'\n"
2781 "new a 100 'exp(-6*x^2)':ranges 0 a.nx-1 0 1\naxis:plot a\n\n"
2782 "pulse b a 'x'\n\ndefine m a.max\n\nline b(1) 0 b(1) m 'r='\n"
2783 "line b(1)-b(3)/2 0  b(1)-b(3)/2 m 'm|'\nline b(1)+b(3)/2 0  b(1)+b(3)/2 m 'm|'\n"
2784 "line 0 0.5*m a.nx-1 0.5*m 'h'\nnew x 100 'x'\nplot b(0)*(1-((x-b(1))/b(2))^2) 'g'";
smgl_pulse(mglGraph * gr)2785 void smgl_pulse(mglGraph *gr)
2786 {
2787 	gr->SubPlot(1,1,0,"<_");
2788 	if(big!=3)	gr->Title("Pulse sample");
2789 	mglData a(100);	gr->Fill(a,"exp(-6*x^2)");
2790 	gr->SetRanges(0, a.nx-1, 0, 1);
2791 	gr->Axis();	gr->Plot(a);
2792 	mglData b(a.Pulse('x'));
2793 	double m = b[0];
2794 	gr->Line(mglPoint(b[1],0), mglPoint(b[1],m),"r=");
2795 	gr->Line(mglPoint(b[1]-b[3]/2,0), mglPoint(b[1]-b[3]/2,m),"m|");
2796 	gr->Line(mglPoint(b[1]+b[3]/2,0), mglPoint(b[1]+b[3]/2,m),"m|");
2797 	gr->Line(mglPoint(0,m/2), mglPoint(a.nx-1,m/2),"h");
2798 	char func[128];	sprintf(func,"%g*(1-((x-%g)/%g)^2)",b[0],b[1],b[2]);
2799 	gr->FPlot(func,"g");
2800 }
2801 //-----------------------------------------------------------------------------
2802 const char *mmgl_scanfile="subplot 1 1 0 '<_':title 'Save and scanfile sample'\n"
2803 "list a 1 -1 0\nsave 'This is test: 0 -> ',a(0),' q' 'test.txt' 'w'\n"
2804 "save 'This is test: 1 -> ',a(1),' q' 'test.txt'\nsave 'This is test: 2 -> ',a(2),' q' 'test.txt'\n"
2805 "\nscanfile a 'test.txt' 'This is test: %g -> %g'\nranges a(0) a(1):axis:plot a(0) a(1) 'o'";
smgl_scanfile(mglGraph * gr)2806 void smgl_scanfile(mglGraph *gr)
2807 {
2808 	gr->SubPlot(1,1,0,"<_");
2809 	if(big!=3)	gr->Title("Save and scanfile sample");
2810 	FILE *fp=fopen("test.txt","w");
2811 	fprintf(fp,"This is test: 0 -> 1 q\n");
2812 	fprintf(fp,"This is test: 1 -> -1 q\n");
2813 	fprintf(fp,"This is test: 2 -> 0 q\n");
2814 	fclose(fp);
2815 
2816 	mglData a;
2817 	a.ScanFile("test.txt","This is test: %g -> %g");
2818 	gr->SetRanges(a.SubData(0), a.SubData(1));
2819 	gr->Axis();	gr->Plot(a.SubData(0),a.SubData(1),"o");
2820 }
2821 //-----------------------------------------------------------------------------
2822 const char *mmgl_pendelta="quality 6\nlist a 0.25 0.5 1 2 4\nfor $0 0 4\n"
2823 "pendelta a($0)\ndefine $1 0.5*$0-1\nline -1 $1 1 $1 'r'\ntext 0 $1 'delta=',a($0)\nnext";
smgl_pendelta(mglGraph * gr)2824 void smgl_pendelta(mglGraph *gr)
2825 {
2826 	double a[5]={0.25,0.5,1,2,4};
2827 	gr->SetQuality(6);
2828 	char buf[64];
2829 	for(int i=0;i<5;i++)
2830 	{
2831 		gr->SetPenDelta(a[i]);
2832 		gr->Line(mglPoint(-1,0.5*i-1), mglPoint(1,0.5*i-1),"r");
2833 		sprintf(buf,"delta=%g",a[i]);
2834 		gr->Puts(mglPoint(0,0.5*i-1),buf);
2835 	}
2836 }
2837 //-----------------------------------------------------------------------------
2838 const char *mmgl_bifurcation="subplot 1 1 0 '<_':title 'Bifurcation sample'\n"
2839 "ranges 0 4 0 1:axis\nbifurcation 0.005 'x*y*(1-y)' 'r'";
smgl_bifurcation(mglGraph * gr)2840 void smgl_bifurcation(mglGraph *gr)
2841 {
2842 	gr->SubPlot(1,1,0,"<_");
2843 	if(big!=3)	gr->Title("Bifurcation sample");
2844 	gr->SetRanges(0,4,0,1);	gr->Axis();
2845 	gr->Bifurcation(0.005,"x*y*(1-y)","r");
2846 }
2847 //-----------------------------------------------------------------------------
2848 const char *mmgl_lamerey="subplot 1 1 0 '<_':title 'Lamerey sample'\n"
2849 "axis:xlabel '\\i x':ylabel '\\bar{\\i x} = 2 \\i{x}'\nfplot 'x' 'k='\nfplot '2*x' 'b'\n"
2850 "lamerey 0.00097 '2*x' 'rv~';size 2\nlamerey -0.00097 '2*x' 'rv~';size 2";
smgl_lamerey(mglGraph * gr)2851 void smgl_lamerey(mglGraph *gr)
2852 {
2853 	gr->SubPlot(1,1,0,"<_");
2854 	if(big!=3)	gr->Title("Lamerey sample");
2855 	gr->Axis();	gr->Label('x',"\\i x");	gr->Label('y',"\\bar{\\i x} = 2 \\i{x}");
2856 	gr->FPlot("x","k=");	gr->FPlot("2*x","b");
2857 	gr->Lamerey( 0.00097,"2*x","rv~");
2858 	gr->Lamerey(-0.00097,"2*x","rv~");
2859 }
2860 //-----------------------------------------------------------------------------
2861 const char *mmgl_pmap="subplot 1 1 0 '<_^':title 'Poincare map sample'\n"
2862 "ode r 'cos(y)+sin(z);cos(z)+sin(x);cos(x)+sin(y)' 'xyz' [0.1,0,0] 0.1 100\n"
2863 "rotate 40 60:copy x r(0):copy y r(1):copy z r(2)\nranges x y z\naxis:plot x y z 'b'\n"
2864 "xlabel '\\i x' 0:ylabel '\\i y' 0:zlabel '\\i z'\n"
2865 "pmap x y z z 'b#o'\nfsurf '0'";
smgl_pmap(mglGraph * gr)2866 void smgl_pmap(mglGraph *gr)
2867 {
2868 	gr->SubPlot(1,1,0,"<_^");
2869 	if(big!=3)	gr->Title("Poincare map sample");
2870 	mglData ini(3);	ini[0]=0.1;
2871 	mglData r(mglODE("cos(y)+sin(z);cos(z)+sin(x);cos(x)+sin(y)","xyz",ini,0.1,100));
2872 	mglData x(r.SubData(0)),y(r.SubData(1)), z(r.SubData(2));
2873 	gr->Rotate(40,60);	gr->SetRanges(x,y,z);
2874 	gr->Axis();	gr->FSurf("0");	gr->Plot(x,y,z,"b");
2875 	gr->Label('x',"\\i x",0);	gr->Label('y',"\\i y",0);	gr->Label('z',"\\i z",0);
2876 	gr->Pmap(x,y,z,z, "b#o");
2877 }
2878 //-----------------------------------------------------------------------------
2879 const char *mmgl_apde="ranges -1 1 0 2 0 2\nnew ar 256 'exp(-2*(x+0.0)^2)'\nnew ai 256\n\n"
2880 "apde res1 'exp(-x^2-p^2)' ar ai 0.01:transpose res1\npde res2 'exp(-x^2-p^2)' ar ai 0.01\n\n"
2881 "subplot 1 2 0 '_':title 'Advanced PDE solver'\nranges 0 2 -1 1:crange res1\ndens res1:box\n"
2882 "axis:xlabel '\\i z':ylabel '\\i x'\n"
2883 "text -0.5 0.2 'i\\partial_z\\i u = exp(-\\i x^2+\\partial_x^2)[\\i u]' 'y'\n\n"
2884 "subplot 1 2 1 '_':title 'Simplified PDE solver'\n"
2885 "dens res2:box\naxis:xlabel '\\i z':ylabel '\\i x'\n"
2886 "text -0.5 0.2 'i\\partial_z\\i u \\approx\\ exp(-\\i x^2)\\i u+exp(\\partial_x^2)[\\i u]' 'y'";
smgl_apde(mglGraph * gr)2887 void smgl_apde(mglGraph *gr)
2888 {
2889 	gr->SetRanges(-1,1,0,2,0,2);
2890 	mglData ar(256), ai(256);	gr->Fill(ar,"exp(-2*(x+0.0)^2)");
2891 
2892 	mglData res1(gr->APDE("exp(-x^2-p^2)",ar,ai,0.01));	res1.Transpose();
2893 	mglData res2(gr->PDE("exp(-x^2-p^2)",ar,ai,0.01));
2894 
2895 	gr->SubPlot(1,2,0,"_");	gr->Title("Advanced PDE solver");
2896 	gr->SetRanges(0,2,-1,1);	gr->SetRange('c',res1);
2897 	gr->Dens(res1);	gr->Axis();	gr->Box();
2898 	gr->Label('x',"\\i z");	gr->Label('y',"\\i x");
2899 	gr->Puts(mglPoint(-0.5,0.2),"i\\partial_z\\i u = exp(-\\i x^2+\\partial_x^2)[\\i u]","y");
2900 
2901 	gr->SubPlot(1,2,1,"_");	gr->Title("Simplified PDE solver");
2902 	gr->Dens(res2);	gr->Axis();	gr->Box();
2903 	gr->Label('x',"\\i z");	gr->Label('y',"\\i x");
2904 	gr->Puts(mglPoint(-0.5,0.2),"i\\partial_z\\i u \\approx\\ exp(-\\i x^2)\\i u+exp(\\partial_x^2)[\\i u]","y");
2905 }
2906 //-----------------------------------------------------------------------------
2907 const char *mmgl_ifs2d="list A [0.33,0,0,0.33,0,0,0.2] [0.33,0,0,0.33,0.67,0,0.2] [0.33,0,0,0.33,0.33,0.33,0.2]\\\n\t"
2908 "[0.33,0,0,0.33,0,0.67,0.2] [0.33,0,0,0.33,0.67,0.67,0.2]\nifs2d fx fy A 100000\n"
2909 "subplot 1 1 0 '<_':title 'IFS 2d sample'\nranges fx fy:axis\nplot fx fy 'r#o ';size 0.05";
smgl_ifs2d(mglGraph * gr)2910 void smgl_ifs2d(mglGraph *gr)
2911 {
2912 	mglData A;
2913 	A.SetList(35, 0.33,0.,0.,0.33,0.,0.,0.2, 0.33,0.,0.,0.33,0.67,0.,0.2, 0.33,0.,0.,0.33,0.33,0.33,0.2, 0.33,0.,0.,0.33,0.,0.67,0.2, 0.33,0.,0.,0.33,0.67,0.67,0.2);
2914 	A.Rearrange(7);
2915 	mglData f(mglIFS2d(A,100000));
2916 	gr->SubPlot(1,1,0,"<_");
2917 	if(big!=3)	gr->Title("IFS 2d sample");
2918 	gr->SetRanges(f.SubData(0), f.SubData(1));
2919 	gr->Axis();	gr->Plot(f.SubData(0), f.SubData(1),"r#o ","size 0.05");
2920 }
2921 //-----------------------------------------------------------------------------
2922 const char *mmgl_icon="setsize 200 200\nzrange 0 2\n\ndefine $s 0.8\nnew x 200 '$s*(x+1)/2*sin(2*pi*x)'\n"
2923 "new y 200 '$s*(x+1)/2*cos(2*pi*x)'\nnew z 200 '$s*(2-(x+1))+0.1'\n"
2924 "new r 200 '0.02+0.07*(x+1)'\n\nsubplot 1 1 0 '#'\nfsurf 'v*cos(2*pi*u)' 'v*sin(2*pi*u)-0.05' 'v/2' 'Yyyww'\n"
2925 "light on\nrotate 65 80\ntube x y z+0.15 r\ndefine $r 0.13\n"
2926 "fsurf '0+$r*cos(2*pi*u)*cos(2*pi*v)' '0.03+$r*cos(2*pi*u)*sin(2*pi*v)' '2*$s+0.25+$r*sin(2*pi*u)' 'r'\n"
2927 "define $r 0.155\nfsurf '$r*cos(2*pi*u)*cos(2*pi*v)' '$s+$r*cos(2*pi*u)*sin(2*pi*v)' '0.25+$r*sin(2*pi*u)' 'b'\n";
smgl_icon(mglGraph * gr)2928 void smgl_icon(mglGraph *gr)
2929 {
2930 	gr->SetSize(200,200);	gr->SetRange('z',0,2);
2931 	mglData x(200);	gr->Fill(x,"0.8*(x+1)/2*sin(2*pi*x)");
2932 	mglData y(200);	gr->Fill(y,"0.8*(x+1)/2*cos(2*pi*x)");
2933 	mglData z(200);	gr->Fill(z,"0.8*(2-(x+1))+0.25");
2934 	mglData r(200);	gr->Fill(r,"0.02+0.07*(x+1)");
2935 	gr->SubPlot(1,1,0,"#");
2936 	gr->FSurf("v*cos(2*pi*u)","v*sin(2*pi*u)-0.05","v/2","Yyyww");
2937 	gr->Light(true);	gr->Rotate(65,80);	gr->Tube(x,y,z,r);
2938 	gr->FSurf("0.13*cos(2*pi*u)*cos(2*pi*v)","0.03+0.13*cos(2*pi*u)*sin(2*pi*v)","1.85+0.13*sin(2*pi*u)","r");
2939 	gr->FSurf("0.155*cos(2*pi*u)*cos(2*pi*v)","0.8+0.155*cos(2*pi*u)*sin(2*pi*v)","0.25+0.155*sin(2*pi*u)","b");
2940 }
2941 //-----------------------------------------------------------------------------
2942 const char *mmgl_ifs3d="list A [0,0,0,0,.18,0,0,0,0,0,0,0,.01] [.85,0,0,0,.85,.1,0,-0.1,0.85,0,1.6,0,.85]\\\n"
2943 "\t[.2,-.2,0,.2,.2,0,0,0,0.3,0,0.8,0,.07] [-.2,.2,0,.2,.2,0,0,0,0.3,0,0.8,0,.07]\n"
2944 "ifs3d f A 100000\ntitle 'IFS 3d sample':rotate 50 60\n"
2945 "ranges f(0) f(1) f(2):axis:box\ndots f(0) f(1) f(2) 'G#o';size 0.05";
smgl_ifs3d(mglGraph * gr)2946 void smgl_ifs3d(mglGraph *gr)
2947 {
2948 	mglData A;
2949 	A.SetList(52, 0.,0.,0.,0.,.18,0.,0.,0.,0.,0.,0.,0.,.01, .85,0.,0.,0.,.85,.1,0.,-0.1,0.85,0.,1.6,0.,.85,
2950 			.2,-.2,0.,.2,.2,0.,0.,0.,0.3,0.,0.8,0.,.07, -.2,.2,0.,.2,.2,0.,0.,0.,0.3,0.,0.8,0.,.07);
2951 	A.Rearrange(13);
2952 	mglData f(mglIFS3d(A,100000));
2953 	if(big!=3)	gr->Title("IFS 3d sample");
2954 	gr->SetRanges(f.SubData(0), f.SubData(1), f.SubData(2));
2955 	gr->Rotate(50,60);	gr->Axis();	gr->Box();
2956 	gr->Dots(f.SubData(0), f.SubData(1), f.SubData(2),"G#o","size 0.05");
2957 }
2958 //-----------------------------------------------------------------------------
2959 const char *mmgl_flame2d="list A [0.33,0,0,0.33,0,0,0.2] [0.33,0,0,0.33,0.67,0,0.2] [0.33,0,0,0.33,0.33,0.33,0.2]\\\n"
2960 "\t[0.33,0,0,0.33,0,0.67,0.2] [0.33,0,0,0.33,0.67,0.67,0.2]\n"
2961 "new B 2 3 A.ny '0.3'\nput B 3 0 0 -1\nput B 3 0 1 -1\nput B 3 0 2 -1\n"
2962 "flame2d fx fy A B 1000000\nsubplot 1 1 0 '<_':title 'Flame2d sample'\n"
2963 "ranges fx fy:box:axis\nplot fx fy 'r#o ';size 0.05";
smgl_flame2d(mglGraph * gr)2964 void smgl_flame2d(mglGraph *gr)
2965 {
2966 	mglData A, B(2,3,5);
2967 	A.SetList(35, 0.33,0.,0.,0.33,0.,0.,0.2, 0.33,0.,0.,0.33,0.67,0.,0.2, 0.33,0.,0.,0.33,0.33,0.33,0.2,
2968 			0.33,0.,0.,0.33,0.,0.67,0.2, 0.33,0.,0.,0.33,0.67,0.67,0.2);
2969 	A.Rearrange(7);
2970 	for(long i=0;i<2*3*5;i++)	B.a[i] = 0.3;
2971 	for(long i=0;i<5;i++)	B.a[2*3*i] = B.a[2*3*i+1*2] = B.a[2*3*i+2*2] = 3;
2972 	mglData f(mglFlame2d(A,B,1000000));
2973 	gr->SubPlot(1,1,0,"<_");
2974 	if(big!=3)	gr->Title("Flame2d sample");
2975 	gr->SetRanges(f.SubData(0), f.SubData(1));
2976 	gr->Axis();	gr->Box();
2977 	gr->Plot(f.SubData(0), f.SubData(1),"r#o ","size 0.05");
2978 }
2979 //-----------------------------------------------------------------------------
2980 const char *mmgl_detect="subplot 1 1 0 '':title 'Detect sample'\n"
2981 "new a 200 100 'exp(-30*(y-0.5*sin(pi*x))^2-rnd/10)+exp(-30*(y+0.5*sin(pi*x))^2-rnd/10)+exp(-30*(x+y)^2-rnd/10)'\n"
2982 "ranges 0 a.nx 0 a.ny:box\nalpha on:crange a:dens a\n\n"
2983 "detect r a 0.1 5\nplot r(0) r(1) '.'";
smgl_detect(mglGraph * gr)2984 void smgl_detect(mglGraph *gr)
2985 {
2986 	mglData a(200, 100);
2987 	gr->Fill(a,"exp(-30*(y-0.5*sin(pi*x))^2-rnd/10)+exp(-30*(y+0.5*sin(pi*x))^2-rnd/10)+exp(-30*(x+y)^2-rnd/10)");
2988 	gr->SubPlot(1,1,0,"");
2989 	if(big!=3)	gr->Title("Detect sample");
2990 	gr->SetRanges(0,a.nx,0,a.ny);	gr->SetRange('c',a);
2991 	gr->Alpha(true);	gr->Box();	gr->Dens(a);
2992 	mglData r(a.Detect(0.1,5));
2993 	gr->Plot(r.SubData(0), r.SubData(1), ".");
2994 }
2995 //-----------------------------------------------------------------------------
2996 const char *mmgl_iris="read a 'iris.dat'\ncrop a 0 4 'x':rearrange a a.nx 50\n"
2997 "subplot 1 1 0 '':title 'Iris plot'\n"
2998 "iris a 'sepal\\n length;sepal\\n width;petal\\n length;petal\\n width' '. ';value -1.5;size -2";
smgl_iris(mglGraph * gr)2999 void smgl_iris(mglGraph *gr)
3000 {
3001 	mglData a("iris.dat");	a.Crop(0,4,'x');	a.Rearrange(4,50);
3002 	gr->SubPlot(1,1,0,"");
3003 	if(big!=3)	gr->Title("Iris sample");
3004 	gr->Iris(a, "sepal\nlength;sepal\nwidth;petal\nlength;petal\nwidth", ". ", "value -1.5;size -2");
3005 }
3006 //-----------------------------------------------------------------------------
3007 const char *mmgl_dilate="subplot 2 2 0:title 'Dilate&Erode 1D sample'\n"
3008 "new y 11:put y 1 5\nranges 0 10 0 1:axis:box\nplot y 'b*'\n"
3009 "dilate y 0.5 2\nplot y 'rs'\nerode y 0.5 1\nplot y 'g#o'\n\n"
3010 "subplot 2 2 1:title 'Dilate&Erode 2D sample':rotate 40 60\n"
3011 "ranges 0 10 0 10 0 3\naxis:box\nnew z 11 11:put z 3 5 5\n"
3012 "boxs z 'b':boxs z 'k#'\ndilate z 1 2\nboxs z 'r':boxs z 'k#'\n"
3013 "erode z 1 1\nboxs 2*z 'g':boxs 2*z 'k#'\n\n"
3014 "subplot 2 2 2\ntext 0.5 0.7 'initial' 'ba';size -2\n"
3015 "text 0.5 0.5 'dilate=2' 'ra';size -2\ntext 0.5 0.3 'erode=1' 'ga';size -2\n\n"
3016 "subplot 2 2 3:title 'Dilate&Erode 3D sample'\nrotate 60 50:light on:alpha on\n"
3017 "ranges 0 10 0 10 0 10:crange 0 3\naxis:box\nnew a 11 11 11:put a 3 5 5 5\n"
3018 "surf3a a a 1.5 'b'\ndilate a 1 2\nsurf3a a a 0.5 'r'\n"
3019 "erode a 1 1\nsurf3a 2*a 2*a 1 'g'";
smgl_dilate(mglGraph * gr)3020 void smgl_dilate(mglGraph *gr)
3021 {
3022 	mglData y(11),	z(11,11), a(11,11,11);
3023 	y.a[5]=1;	z.a[5+11*5]=a.a[5+11*(5+11*5)] = 3;
3024 
3025 	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Dilate&Erode 1D sample");	}
3026 	else	gr->SubPlot(1,1,0,"");
3027 	gr->SetRanges(0,10,0,1);	gr->Axis();	gr->Box();	gr->Plot(y,"b*");
3028 	y.Dilate(1,2);	gr->Plot(y,"rs");
3029 	y.Erode(1,1);	gr->Plot(y,"g#o");
3030 	if(big==3)	return;
3031 
3032 	gr->SubPlot(2,2,1);	gr->Title("Dilate&Erode 2D sample");
3033 	gr->Rotate(40,60);	gr->SetRanges(0,10,0,10,0,3);
3034 	gr->Axis();	gr->Box();	gr->Boxs(z,"b");	gr->Boxs(z,"k#");
3035 	z.Dilate(1,2);			gr->Boxs(z,"r");	gr->Boxs(z,"k#");
3036 	z.Erode(1,1);	z*=2;	gr->Boxs(z,"g");	gr->Boxs(z,"k#");
3037 
3038 	gr->SubPlot(2,2,2);
3039 	gr->Puts(0.5,0.7,"initial","ba",-2);
3040 	gr->Puts(0.5,0.5,"dilate=2","ra",-2);
3041 	gr->Puts(0.5,0.3,"erode=1","ga",-2);
3042 
3043 	gr->SubPlot(2,2,3);	gr->Title("Dilate&Erode 3D sample");
3044 	gr->Rotate(60,50);	gr->Alpha(true);	gr->Light(true);
3045 	gr->SetRanges(0,10,0,10,0,10);	gr->SetRange('c',0,3);
3046 	gr->Axis();	gr->Box();	gr->Surf3A(1.5,a,a,"b");
3047 	a.Dilate(1,2);			gr->Surf3A(0.5,a,a,"r");
3048 	a.Erode(1,1);	a*=2;	gr->Surf3A(1,a,a,"g");
3049 }
3050 //-----------------------------------------------------------------------------
3051 const char *mmgl_section="subplot 1 1 0 '<_':title 'Section&Join sample'\n"
3052 "axis:box:line -1 0 1 0 'h:'\n# first lets demonstrate 'join'\n"
3053 "new aa 11 'x^2':new a1 3 '-x':new a2 15 'x^3'\njoin aa a1:join aa a2\n"
3054 "# add x-coordinate\nnew xx aa.nx 'x':join aa xx\nplot aa(:,1) aa(:,0) '2y'\n"
3055 "# now select 1-st (id=0) section between zeros\n"
3056 "section b1 aa 0 'x' 0\nplot b1(:,1) b1(:,0) 'bo'\n"
3057 "# next, select 3-d (id=2) section between zeros\n"
3058 "section b3 aa 2 'x' 0\nplot b3(:,1) b3(:,0) 'gs'\n"
3059 "# finally, select 2-nd (id=-2) section from the end\n"
3060 "section b4 aa -2 'x' 0\nplot b4(:,1) b4(:,0) 'r#o'";
smgl_section(mglGraph * gr)3061 void smgl_section(mglGraph *gr)
3062 {
3063 	gr->SubPlot(1,1,0,"<_");
3064 	if(big!=3)	gr->Title("Section&Join sample");
3065 	gr->Axis();	gr->Box();	gr->Line(mglPoint(-1,0),mglPoint(1,0),"h:");
3066 	// first lets demonstrate 'join'
3067 	mglData aa(11), a1(3), a2(15);
3068 	gr->Fill(aa,"x^2");	gr->Fill(a1,"-x");	gr->Fill(a2,"x^3");
3069 	aa.Join(a1);	aa.Join(a2);
3070 	// add x-coordinate
3071 	mglData xx(aa.nx);	gr->Fill(xx,"x");	aa.Join(xx);
3072 	gr->Plot(aa.SubData(-1,1), aa.SubData(-1,0), "2y");
3073 	// now select 1-st (id=0) section between zeros
3074 	mglData b1(aa.Section(0,'x',0));
3075 	gr->Plot(b1.SubData(-1,1), b1.SubData(-1,0), "bo");
3076 	// next, select 3-d (id=2) section between zeros
3077 	mglData b2(aa.Section(2,'x',0));
3078 	gr->Plot(b2.SubData(-1,1), b2.SubData(-1,0), "gs");
3079 	// finally, select 2-nd (id=-2) section from the end
3080 	mglData b3(aa.Section(-2,'x',0));
3081 	gr->Plot(b3.SubData(-1,1), b3.SubData(-1,0), "r#o");
3082 }
3083 //-----------------------------------------------------------------------------
3084 const char *mmgl_3wave="define t 50\n"
3085 "ode !r '-b*f;a*conj(f);a*conj(b)-0.1*f' 'abf' [1,1e-3,0] 0.1 t\n"
3086 "ranges 0 t 0 r.max\nplot r(0) 'b';legend 'a'\n"
3087 "plot r(1) 'g';legend 'b'\nplot r(2) 'r';legend 'f'\n"
3088 "axis:box:legend";
smgl_3wave(mglGraph * gr)3089 void smgl_3wave(mglGraph *gr)
3090 {
3091 	gr->SubPlot(1,1,0,"<_");
3092 	if(big!=3)	gr->Title("Complex ODE sample");
3093 	double t=50;
3094 	mglData ini;	ini.SetList(3, 1., 1e-3, 0.);
3095 	mglDataC r(mglODEc("-b*f;a*conj(f);a*conj(b)-0.1*f","abf",ini,0.1,t));
3096 	gr->SetRanges(0, t, 0, r.Maximal());
3097 	gr->Plot(r.SubData(0),"b","legend 'a'");
3098 	gr->Plot(r.SubData(1),"g","legend 'b'");
3099 	gr->Plot(r.SubData(2),"r","legend 'f'");
3100 	gr->Axis();	gr->Box();	gr->Legend();
3101 }
3102 //-----------------------------------------------------------------------------
3103 const char *mmgl_diffract="define n 32	#number of points\ndefine m 20 # number of iterations\n"
3104 "define dt 0.01 # time step\nnew res n m+1\nranges -1 1 0 m*dt 0 1\n\n"
3105 "#tridmat periodic variant\nnew !a n 'i',dt*(n/2)^2/2\ncopy !b !(1-2*a)\n\n"
3106 "new !u n 'exp(-6*x^2)'\nput res u all 0\nfor $i 0 m\ntridmat u a b a u 'xdc'\n"
3107 "put res u all $i+1\nnext\nsubplot 2 2 0 '<_':title 'Tridmat, periodic b.c.'\naxis:box:dens res\n\n"
3108 "#fourier variant\nnew k n:fillsample k 'xk'\ncopy !e !exp(-i1*dt*k^2)\n\n"
3109 "new !u n 'exp(-6*x^2)'\nput res u all 0\nfor $i 0 m\nfourier u 'x'\nmulto u e\nfourier u 'ix'\n"
3110 "put res u all $i+1\nnext\nsubplot 2 2 1 '<_':title 'Fourier method'\naxis:box:dens res\n\n"
3111 "#tridmat zero variant\nnew !u n 'exp(-6*x^2)'\nput res u all 0\nfor $i 0 m\ntridmat u a b a u 'xd'\n"
3112 "put res u all $i+1\nnext\nsubplot 2 2 2 '<_':title 'Tridmat, zero b.c.'\naxis:box:dens res\n\n"
3113 "#diffract exp variant\nnew !u n 'exp(-6*x^2)'\ndefine q dt*(n/2)^2/8 # need q<0.4 !!!\n"
3114 "put res u all 0\nfor $i 0 m\nfor $j 1 8	# due to smaller dt\ndiffract u 'xe' q\nnext\n"
3115 "put res u all $i+1\nnext\nsubplot 2 2 3 '<_':title 'Diffract, exp b.c.'\naxis:box:dens res";
smgl_diffract(mglGraph * gr)3116 void smgl_diffract(mglGraph *gr)
3117 {
3118 	long n=32;	// number of points
3119 	long m=20;	// number of iterations
3120 	double dt=0.01;	// time step
3121 	mglData res(n,m+1);
3122 	gr->SetRanges(-1,1, 0,m*dt, 0,1);
3123 
3124 	// tridmat periodic variant
3125 	mglDataC a(n), b(n);	a = dual(0,dt*n*n/8);
3126 	for(long i=0;i<n;i++)	b.a[i] = mreal(1)-mreal(2)*a.a[i];
3127 	mglDataC u(n);	gr->Fill(u,"exp(-6*x^2)");	res.Put(u,-1,0);
3128 	for(long i=0;i<m;i++)
3129 	{
3130 		u = mglTridMatC(a,b,a,u,"xdc");
3131 		res.Put(u,-1,i+1);
3132 	}
3133 	gr->SubPlot(2,2,0,"<_");	gr->Title("Tridmat, periodic b.c.");
3134 	gr->Axis();	gr->Box();	gr->Dens(res);
3135 
3136 	// fourier variant
3137 	mglData k(n);	k.FillSample("xk");
3138 	mglDataC e(n);	for(long i=0;i<n;i++)	e.a[i] = exp(-dual(0,dt*k.a[i]*k.a[i]));
3139 	gr->Fill(u,"exp(-6*x^2)");	res.Put(u,-1,0);
3140 	for(long i=0;i<m;i++)
3141 	{
3142 		u.FFT("x");	u *= e;	u.FFT("ix");
3143 		res.Put(u,-1,i+1);
3144 	}
3145 	gr->SubPlot(2,2,1,"<_");	gr->Title("Fourier method");
3146 	gr->Axis();	gr->Box();	gr->Dens(res);
3147 
3148 	// tridmat zero variant
3149 	gr->Fill(u,"exp(-6*x^2)");	res.Put(u,-1,0);
3150 	for(long i=0;i<m;i++)
3151 	{
3152 		u = mglTridMatC(a,b,a,u,"xd");
3153 		res.Put(u,-1,i+1);
3154 	}
3155 	gr->SubPlot(2,2,2,"<_");	gr->Title("Tridmat, zero b.c.");
3156 	gr->Axis();	gr->Box();	gr->Dens(res);
3157 
3158 	// diffract exp variant
3159 	gr->Fill(u,"exp(-6*x^2)");	res.Put(u,-1,0);
3160 	double q=dt*n*n/4/8;	// NOTE: need q<0.4 !!!
3161 	for(long i=0;i<m;i++)
3162 	{
3163 		for(long j=0;j<8;j++)	// due to smaller dt
3164 			u.Diffraction("xe",q);
3165 		res.Put(u,-1,i+1);
3166 	}
3167 	gr->SubPlot(2,2,3,"<_");	gr->Title("Diffract, exp b.c.");
3168 	gr->Axis();	gr->Box();	gr->Dens(res);
3169 }
3170 //-----------------------------------------------------------------------------
3171 const char *mmgl_earth="import dat 'Equirectangular-projection.jpg' 'BbGYw' -1 1\n"
3172 "subplot 1 1 0 '<>':title 'Earth in 3D':rotate 40 60\n"
3173 "copy phi dat 'pi*x':copy tet dat 'pi*y/2'\n"
3174 "copy x cos(tet)*cos(phi)\ncopy y cos(tet)*sin(phi)\ncopy z sin(tet)\n\n"
3175 "light on\nsurfc x y z dat 'BbGYw'\ncontp [-0.51,-0.51] x y z dat 'y'";
smgl_earth(mglGraph * gr)3176 void smgl_earth(mglGraph *gr)
3177 {
3178 	mglData dat;	dat.Import("Equirectangular-projection.jpg","BbGYw",-1,1);
3179 	// Calc proper 3d coordinates from projection
3180 	mglData phi(dat.nx,dat.ny);	phi.Fill(-M_PI,M_PI);
3181 	mglData tet(dat.nx,dat.ny);	tet.Fill(-M_PI/2,M_PI/2,'y');
3182 	mglData x(dat.nx,dat.ny), y(dat.nx,dat.ny), z(dat.nx,dat.ny);
3183 #pragma omp parallel for
3184 	for(long i=0;i<dat.nx*dat.ny;i++)
3185 	{	x.a[i] = cos(tet.a[i])*cos(phi.a[i]);
3186 		y.a[i] = cos(tet.a[i])*sin(phi.a[i]);
3187 		z.a[i] = sin(tet.a[i]);	}
3188 
3189 	gr->SubPlot(1,1,0,"<>");
3190 	if(big!=3)	gr->Title("Earth in 3D");
3191 	gr->Rotate(40,60);	gr->Light(true);
3192 	gr->SurfC(x,y,z,dat,"BbGYw");
3193 	mglData vals(1);	vals.a[0]=-0.51;
3194 	gr->ContP(vals, x,y,z,dat,"y");
3195 }
3196 //-----------------------------------------------------------------------------
3197 #define all_prims_str "subplot 3 2 0:define y 0.95\n\
3198 define d 0.3:define x0 0.2:define x1 0.5:define x2 0.6\n\
3199 line x0 1-0*d x1 1-0*d 'k-':text x2 y-0*d 'Solid `-`' ':rL'\n\
3200 line x0 1-1*d x1 1-1*d 'k|':text x2 y-1*d 'Long Dash `|`' ':rL'\n\
3201 line x0 1-2*d x1 1-2*d 'k;':text x2 y-2*d 'Dash 1;`' ':rL'\n\
3202 line x0 1-3*d x1 1-3*d 'k=':text x2 y-3*d 'Small dash `=`' ':rL'\n\
3203 line x0 1-4*d x1 1-4*d 'kj':text x2 y-4*d 'Dash-dot `j`' ':rL'\n\
3204 line x0 1-5*d x1 1-5*d 'ki':text x2 y-5*d 'Small dash-dot `i`' ':rL'\n\
3205 line x0 1-6*d x1 1-6*d 'k:':text x2 y-6*d 'Dots `:`' ':rL'\n\
3206 line x0 1-7*d x1 1-7*d 'k ':text x2 y-7*d 'None ``' ':rL'\n\
3207 define d 0.25:define x0 -0.8:define x1 -1:define x2 -0.05\n\
3208 ball x1 5*d 'k.':text x0 5*d '.' ':rL'\n\
3209 ball x1 4*d 'k+':text x0 4*d '+' ':rL'\n\
3210 ball x1 3*d 'kx':text x0 3*d 'x' ':rL'\n\
3211 ball x1 2*d 'k*':text x0 2*d '*' ':rL'\n\
3212 ball x1 d 'ks':text x0 d 's' ':rL'\n\
3213 ball x1 0 'kd':text x0 0 'd' ':rL'\n\
3214 ball x1 -d 0 'ko':text x0 y-d 'o' ':rL'\n\
3215 ball x1 -2*d 0 'k^':text x0 -2*d '\\^' ':rL'\n\
3216 ball x1 -3*d 0 'kv':text x0 -3*d 'v' ':rL'\n\
3217 ball x1 -4*d 0 'k<':text x0 -4*d '<' ':rL'\n\
3218 ball x1 -5*d 0 'k>':text x0 -5*d '>' ':rL'\n\n\
3219 define x0 -0.3:define x1 -0.5\n\
3220 ball x1 5*d 'k#.':text x0 5*d '\\#.' ':rL'\n\
3221 ball x1 4*d 'k#+':text x0 4*d '\\#+' ':rL'\n\
3222 ball x1 3*d 'k#x':text x0 3*d '\\#x' ':rL'\n\
3223 ball x1 2*d 'k#*':text x0 2*d '\\#*' ':rL'\n\
3224 ball x1 d 'k#s':text x0 d '\\#s' ':rL'\n\
3225 ball x1 0 'k#d':text x0 0 '\\#d' ':rL'\n\
3226 ball x1 -d 0 'k#o':text x0 -d '\\#o' ':rL'\n\
3227 ball x1 -2*d 0 'k#^':text x0 -2*d '\\#\\^' ':rL'\n\
3228 ball x1 -3*d 0 'k#v':text x0 -3*d '\\#v' ':rL'\n\
3229 ball x1 -4*d 0 'k#<':text x0 -4*d '\\#<' ':rL'\n\
3230 ball x1 -5*d 0 'k#>':text x0 -5*d '\\#>' ':rL'\n\n\
3231 subplot 3 2 1\ndefine a 0.1:define b 0.4:define c 0.5\n\
3232 line a 1 b 1 'k-A':text c 1 'Style `A` or `A\\_`' ':rL'\n\
3233 line a 0.8 b 0.8 'k-V':text c 0.8 'Style `V` or `V\\_`' ':rL'\n\
3234 line a 0.6 b 0.6 'k-K':text c 0.6 'Style `K` or `K\\_`' ':rL'\n\
3235 line a 0.4 b 0.4 'k-I':text c 0.4 'Style `I` or `I\\_`' ':rL'\n\
3236 line a 0.2 b 0.2 'k-D':text c 0.2 'Style `D` or `D\\_`' ':rL'\n\
3237 line a 0 b 0 'k-S':text c 0 'Style `S` or `S\\_`' ':rL'\n\
3238 line a -0.2 b -0.2 'k-O':text c -0.2 'Style `O` or `O\\_`' ':rL'\n\
3239 line a -0.4 b -0.4 'k-T':text c -0.4 'Style `T` or `T\\_`' ':rL'\n\
3240 line a -0.6 b -0.6 'k-_':text c -0.6 'Style `\\_` or none' ':rL'\n\
3241 line a -0.8 b -0.8 'k-AS':text c -0.8 'Style `AS`' ':rL'\n\
3242 line a -1 b -1 'k-_A':text c -1 'Style `\\_A`' ':rL'\n\n\
3243 define a -1:define b -0.7:define c -0.6\n\
3244 line a 1 b 1 'kAA':text c 1 'Style `AA`' ':rL'\n\
3245 line a 0.8 b 0.8 'kVV':text c 0.8 'Style `VV`' ':rL'\n\
3246 line a 0.6 b 0.6 'kKK':text c 0.6 'Style `KK`' ':rL'\n\
3247 line a 0.4 b 0.4 'kII':text c 0.4 'Style `II`' ':rL'\n\
3248 line a 0.2 b 0.2 'kDD':text c 0.2 'Style `DD`' ':rL'\n\
3249 line a 0 b 0 'kSS':text c 0 'Style `SS`' ':rL'\n\
3250 line a -0.2 b -0.2 'kOO':text c -0.2 'Style `OO`' ':rL'\n\
3251 line a -0.4 b -0.4 'kTT':text c -0.4 'Style `TT`' ':rL'\n\
3252 line a -0.6 b -0.6 'k-__':text c -0.6 'Style `\\_\\_`' ':rL'\n\
3253 line a -0.8 b -0.8 'k-VA':text c -0.8 'Style `VA`' ':rL'\n\
3254 line a -1 b -1 'k-AV':text c -1 'Style `AV`' ':rL'\n\n\
3255 subplot 3 2 2\n#LENUQ\n\n\
3256 facez -1 -1 0 0.4 0.3 'L#':text -0.8 -0.9 'L' 'w:C' -1.4\n\
3257 facez -0.6 -1 0 0.4 0.3 'E#':text -0.4 -0.9 'E' 'w:C' -1.4\n\
3258 facez -0.2 -1 0 0.4 0.3 'N#':text 0 -0.9 'N' 'w:C' -1.4\n\
3259 facez 0.2 -1 0 0.4 0.3 'U#':text 0.4 -0.9 'U' 'w:C' -1.4\n\
3260 facez 0.6 -1 0 0.4 0.3 'Q#':text 0.8 -0.9 'Q' 'w:C' -1.4\n\
3261 #lenuq\nfacez -1 -0.7 0 0.4 0.3 'l#':text -0.8 -0.6 'l' 'k:C' -1.4\n\
3262 facez -0.6 -0.7 0 0.4 0.3 'e#':text -0.4 -0.6 'e' 'k:C' -1.4\n\
3263 facez -0.2 -0.7 0 0.4 0.3 'n#':text 0 -0.6 'n' 'k:C' -1.4\n\
3264 facez 0.2 -0.7 0 0.4 0.3 'u#':text 0.4 -0.6 'u' 'k:C' -1.4\n\
3265 facez 0.6 -0.7 0 0.4 0.3 'q#':text 0.8 -0.6 'q' 'k:C' -1.4\n\
3266 #CMYkP\nfacez -1 -0.4 0 0.4 0.3 'C#':text -0.8 -0.3 'C' 'w:C' -1.4\n\
3267 facez -0.6 -0.4 0 0.4 0.3 'M#':text -0.4 -0.3 'M' 'w:C' -1.4\n\
3268 facez -0.2 -0.4 0 0.4 0.3 'Y#':text 0 -0.3 'Y' 'w:C' -1.4\n\
3269 facez 0.2 -0.4 0 0.4 0.3 'k#':text 0.4 -0.3 'k' 'w:C' -1.4\n\
3270 facez 0.6 -0.4 0 0.4 0.3 'P#':text 0.8 -0.3 'P' 'w:C' -1.4\n\
3271 #cmywp\nfacez -1 -0.1 0 0.4 0.3 'c#':text -0.8 0 'c' 'k:C' -1.4\n\
3272 facez -0.6 -0.1 0 0.4 0.3 'm#':text -0.4 0 'm' 'k:C' -1.4\n\
3273 facez -0.2 -0.1 0 0.4 0.3 'y#':text 0 0 'y' 'k:C' -1.4\n\
3274 facez 0.2 -0.1 0 0.4 0.3 'w#':text 0.4 0 'w' 'k:C' -1.4\n\
3275 facez 0.6 -0.1 0 0.4 0.3 'p#':text 0.8 0 'p' 'k:C' -1.4\n\
3276 #BGRHW\nfacez -1 0.2 0 0.4 0.3 'B#':text -0.8 0.3 'B' 'w:C' -1.4\n\
3277 facez -0.6 0.2 0 0.4 0.3 'G#':text -0.4 0.3 'G' 'w:C' -1.4\n\
3278 facez -0.2 0.2 0 0.4 0.3 'R#':text 0 0.3 'R' 'w:C' -1.4\n\
3279 facez 0.2 0.2 0 0.4 0.3 'H#':text 0.4 0.3 'H' 'w:C' -1.4\n\
3280 facez 0.6 0.2 0 0.4 0.3 'W#':text 0.8 0.3 'W' 'w:C' -1.4\n\
3281 #bgrhw\nfacez -1 0.5 0 0.4 0.3 'b#':text -0.8 0.6 'b' 'k:C' -1.4\n\
3282 facez -0.6 0.5 0 0.4 0.3 'g#':text -0.4 0.6 'g' 'k:C' -1.4\n\
3283 facez -0.2 0.5 0 0.4 0.3 'r#':text 0 0.6 'r' 'k:C' -1.4\n\
3284 facez 0.2 0.5 0 0.4 0.3 'h#':text 0.4 0.6 'h' 'k:C' -1.4\n\
3285 facez 0.6 0.5 0 0.4 0.3 'w#':text 0.8 0.6 'w' 'k:C' -1.4\n\
3286 #brighted\nfacez -1 0.8 0 0.4 0.3 '{r1}#':text -0.8 0.9 '\\{r1\\}' 'w:C' -1.4\n\
3287 facez -0.6 0.8 0 0.4 0.3 '{r3}#':text -0.4 0.9 '\\{r3\\}' 'w:C' -1.4\n\
3288 facez -0.2 0.8 0 0.4 0.3 '{r5}#':text 0 0.9 '\\{r5\\}' 'k:C' -1.4\n\
3289 facez 0.2 0.8 0 0.4 0.3 '{r7}#':text 0.4 0.9 '\\{r7\\}' 'k:C' -1.4\n\
3290 facez 0.6 0.8 0 0.4 0.3 '{r9}#':text 0.8 0.9 '\\{r9\\}' 'k:C' -1.4\n\
3291 # HEX\nfacez -1 -1.3 0 1 0.3 '{xff9966}#':text -0.5 -1.2 '\\{xff9966\\}' 'k:C' -1.4\n\
3292 facez 0 -1.3 0 1 0.3 '{x83CAFF}#':text 0.5 -1.2 '\\{x83caff\\}' 'k:C' -1.4\n\n\
3293 subplot 3 2 3\nfor $i 0 9\nline -1 0.2*$i-1 1 0.2*$i-1 'r','0'+$i\n\
3294 text 1.05 0.2*$i-1 '0'+$i ':L'\nnext\n\n\
3295 subplot 3 2 4:title 'TriPlot sample':rotate 50 60\n\
3296 list tt 0 1 2 | 0 1 3 | 0 2 3 | 1 2 3\n\
3297 list xt -1 1 0 0:list yt -1 -1 1 0:list zt -1 -1 -1 1:light on\n\
3298 triplot tt xt yt zt 'b':triplot tt xt yt zt 'k#'\n\n\
3299 subplot 3 2 5:new r 4 'i+1':ranges 1 4 1 4\naxis:mark r r 's':plot r 'b'\n"
all_prims(mglGraph * gr)3300 void all_prims(mglGraph *gr)	// test drawing of all kinds
3301 {
3302 	gr->SubPlot(3,2,0);
3303 	double d,x1,x2,x0,y=0.95;
3304 	d=0.3, x0=0.2, x1=0.5, x2=0.6;
3305 	gr->Line(mglPoint(x0,1-0*d),mglPoint(x1,1-0*d),"k-");	gr->Puts(mglPoint(x2,y-0*d),"Solid '-'",":rL");
3306 	gr->Line(mglPoint(x0,1-1*d),mglPoint(x1,1-1*d),"k|");	gr->Puts(mglPoint(x2,y-1*d),"Long Dash '|'",":rL");
3307 	gr->Line(mglPoint(x0,1-2*d),mglPoint(x1,1-2*d),"k;");	gr->Puts(mglPoint(x2,y-2*d),"Dash ';'",":rL");
3308 	gr->Line(mglPoint(x0,1-3*d),mglPoint(x1,1-3*d),"k=");	gr->Puts(mglPoint(x2,y-3*d),"Small dash '='",":rL");
3309 	gr->Line(mglPoint(x0,1-4*d),mglPoint(x1,1-4*d),"kj");	gr->Puts(mglPoint(x2,y-4*d),"Dash-dot 'j'",":rL");
3310 	gr->Line(mglPoint(x0,1-5*d),mglPoint(x1,1-5*d),"ki");	gr->Puts(mglPoint(x2,y-5*d),"Small dash-dot 'i'",":rL");
3311 	gr->Line(mglPoint(x0,1-6*d),mglPoint(x1,1-6*d),"k:");	gr->Puts(mglPoint(x2,y-6*d),"Dots ':'",":rL");
3312 	gr->Line(mglPoint(x0,1-7*d),mglPoint(x1,1-7*d),"k ");	gr->Puts(mglPoint(x2,y-7*d),"None ' '",":rL");
3313 
3314 	d=0.25; x1=-1; x0=-0.8;	y = -0.05;
3315 	gr->Mark(mglPoint(x1,5*d),"k.");	gr->Puts(mglPoint(x0,y+5*d),"'.'",":rL");
3316 	gr->Mark(mglPoint(x1,4*d),"k+");	gr->Puts(mglPoint(x0,y+4*d),"'+'",":rL");
3317 	gr->Mark(mglPoint(x1,3*d),"kx");	gr->Puts(mglPoint(x0,y+3*d),"'x'",":rL");
3318 	gr->Mark(mglPoint(x1,2*d),"k*");	gr->Puts(mglPoint(x0,y+2*d),"'*'",":rL");
3319 	gr->Mark(mglPoint(x1,d),"ks");		gr->Puts(mglPoint(x0,y+d),"'s'",":rL");
3320 	gr->Mark(mglPoint(x1,0),"kd");		gr->Puts(mglPoint(x0,y),"'d'",":rL");
3321 	gr->Mark(mglPoint(x1,-d,0),"ko");	gr->Puts(mglPoint(x0,y-d),"'o'",":rL");
3322 	gr->Mark(mglPoint(x1,-2*d,0),"k^");	gr->Puts(mglPoint(x0,y-2*d),"'\\^'",":rL");
3323 	gr->Mark(mglPoint(x1,-3*d,0),"kv");	gr->Puts(mglPoint(x0,y-3*d),"'v'",":rL");
3324 	gr->Mark(mglPoint(x1,-4*d,0),"k<");	gr->Puts(mglPoint(x0,y-4*d),"'<'",":rL");
3325 	gr->Mark(mglPoint(x1,-5*d,0),"k>");	gr->Puts(mglPoint(x0,y-5*d),"'>'",":rL");
3326 
3327 	d=0.25; x1=-0.5; x0=-0.3;	y = -0.05;
3328 	gr->Mark(mglPoint(x1,5*d),"k#.");	gr->Puts(mglPoint(x0,y+5*d),"'\\#.'",":rL");
3329 	gr->Mark(mglPoint(x1,4*d),"k#+");	gr->Puts(mglPoint(x0,y+4*d),"'\\#+'",":rL");
3330 	gr->Mark(mglPoint(x1,3*d),"k#x");	gr->Puts(mglPoint(x0,y+3*d),"'\\#x'",":rL");
3331 	gr->Mark(mglPoint(x1,2*d),"k#*");	gr->Puts(mglPoint(x0,y+2*d),"'\\#*'",":rL");
3332 	gr->Mark(mglPoint(x1,d),"k#s");		gr->Puts(mglPoint(x0,y+d),"'\\#s'",":rL");
3333 	gr->Mark(mglPoint(x1,0),"k#d");		gr->Puts(mglPoint(x0,y),"'\\#d'",":rL");
3334 	gr->Mark(mglPoint(x1,-d,0),"k#o");	gr->Puts(mglPoint(x0,y-d),"'\\#o'",":rL");
3335 	gr->Mark(mglPoint(x1,-2*d,0),"k#^");	gr->Puts(mglPoint(x0,y-2*d),"'\\#\\^'",":rL");
3336 	gr->Mark(mglPoint(x1,-3*d,0),"k#v");	gr->Puts(mglPoint(x0,y-3*d),"'\\#v'",":rL");
3337 	gr->Mark(mglPoint(x1,-4*d,0),"k#<");	gr->Puts(mglPoint(x0,y-4*d),"'\\#<'",":rL");
3338 	gr->Mark(mglPoint(x1,-5*d,0),"k#>");	gr->Puts(mglPoint(x0,y-5*d),"'\\#>'",":rL");
3339 
3340 	gr->SubPlot(3,2,1);
3341 	double a=0.1,b=0.4,c=0.5;
3342 	gr->Line(mglPoint(a,1),mglPoint(b,1),"k-A");		gr->Puts(mglPoint(c,1),"Style 'A' or 'A\\_'",":rL");
3343 	gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"k-V");	gr->Puts(mglPoint(c,0.8),"Style 'V' or 'V\\_'",":rL");
3344 	gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"k-K");	gr->Puts(mglPoint(c,0.6),"Style 'K' or 'K\\_'",":rL");
3345 	gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"k-I");	gr->Puts(mglPoint(c,0.4),"Style 'I' or 'I\\_'",":rL");
3346 	gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"k-D");	gr->Puts(mglPoint(c,0.2),"Style 'D' or 'D\\_'",":rL");
3347 	gr->Line(mglPoint(a,0),mglPoint(b,0),"k-S");		gr->Puts(mglPoint(c,0),"Style 'S' or 'S\\_'",":rL");
3348 	gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"k-O");	gr->Puts(mglPoint(c,-0.2),"Style 'O' or 'O\\_'",":rL");
3349 	gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"k-T");	gr->Puts(mglPoint(c,-0.4),"Style 'T' or 'T\\_'",":rL");
3350 	gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-_");	gr->Puts(mglPoint(c,-0.6),"Style '\\_' or none",":rL");
3351 	gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-AS");	gr->Puts(mglPoint(c,-0.8),"Style 'AS'",":rL");
3352 	gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-_A");		gr->Puts(mglPoint(c,-1),"Style '\\_A'",":rL");
3353 
3354 	a=-1;	b=-0.7;	c=-0.6;
3355 	gr->Line(mglPoint(a,1),mglPoint(b,1),"kAA");		gr->Puts(mglPoint(c,1),"Style 'AA'",":rL");
3356 	gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"kVV");	gr->Puts(mglPoint(c,0.8),"Style 'VV'",":rL");
3357 	gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"kKK");	gr->Puts(mglPoint(c,0.6),"Style 'KK'",":rL");
3358 	gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"kII");	gr->Puts(mglPoint(c,0.4),"Style 'II'",":rL");
3359 	gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"kDD");	gr->Puts(mglPoint(c,0.2),"Style 'DD'",":rL");
3360 	gr->Line(mglPoint(a,0),mglPoint(b,0),"kSS");		gr->Puts(mglPoint(c,0),"Style 'SS'",":rL");
3361 	gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"kOO");	gr->Puts(mglPoint(c,-0.2),"Style 'OO'",":rL");
3362 	gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"kTT");	gr->Puts(mglPoint(c,-0.4),"Style 'TT'",":rL");
3363 	gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-__");	gr->Puts(mglPoint(c,-0.6),"Style '\\_\\_'",":rL");
3364 	gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-VA");	gr->Puts(mglPoint(c,-0.8),"Style 'VA'",":rL");
3365 	gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-AV");		gr->Puts(mglPoint(c,-1),"Style 'AV'",":rL");
3366 
3367 	gr->SubPlot(3,2,2);
3368 	//#LENUQ
3369 	gr->FaceZ(mglPoint(-1,	-1), 0.4, 0.3, "L#");	gr->Puts(mglPoint(-0.8,-0.9), "L", "w:C", -1.4);
3370 	gr->FaceZ(mglPoint(-0.6,-1), 0.4, 0.3, "E#");	gr->Puts(mglPoint(-0.4,-0.9), "E", "w:C", -1.4);
3371 	gr->FaceZ(mglPoint(-0.2,-1), 0.4, 0.3, "N#");	gr->Puts(mglPoint(0,  -0.9), "N", "w:C", -1.4);
3372 	gr->FaceZ(mglPoint(0.2,	-1), 0.4, 0.3, "U#");	gr->Puts(mglPoint(0.4,-0.9), "U", "w:C", -1.4);
3373 	gr->FaceZ(mglPoint(0.6,	-1), 0.4, 0.3, "Q#");	gr->Puts(mglPoint(0.8,-0.9), "Q", "w:C", -1.4);
3374 	//#lenuq
3375 	gr->FaceZ(mglPoint(-1,	-0.7), 0.4, 0.3, "l#");	gr->Puts(mglPoint(-0.8,-0.6), "l", "k:C", -1.4);
3376 	gr->FaceZ(mglPoint(-0.6,-0.7), 0.4, 0.3, "e#");	gr->Puts(mglPoint(-0.4,-0.6), "e", "k:C", -1.4);
3377 	gr->FaceZ(mglPoint(-0.2,-0.7), 0.4, 0.3, "n#");	gr->Puts(mglPoint(0,  -0.6), "n", "k:C", -1.4);
3378 	gr->FaceZ(mglPoint(0.2,	-0.7), 0.4, 0.3, "u#");	gr->Puts(mglPoint(0.4,-0.6), "u", "k:C", -1.4);
3379 	gr->FaceZ(mglPoint(0.6,	-0.7), 0.4, 0.3, "q#");	gr->Puts(mglPoint(0.8,-0.6), "q", "k:C", -1.4);
3380 	//#CMYkP
3381 	gr->FaceZ(mglPoint(-1,	-0.4), 0.4, 0.3, "C#");	gr->Puts(mglPoint(-0.8,-0.3), "C", "w:C", -1.4);
3382 	gr->FaceZ(mglPoint(-0.6,-0.4), 0.4, 0.3, "M#");	gr->Puts(mglPoint(-0.4,-0.3), "M", "w:C", -1.4);
3383 	gr->FaceZ(mglPoint(-0.2,-0.4), 0.4, 0.3, "Y#");	gr->Puts(mglPoint(0,  -0.3), "Y", "w:C", -1.4);
3384 	gr->FaceZ(mglPoint(0.2,	-0.4), 0.4, 0.3, "k#");	gr->Puts(mglPoint(0.4,-0.3), "k", "w:C", -1.4);
3385 	gr->FaceZ(mglPoint(0.6,	-0.4), 0.4, 0.3, "P#");	gr->Puts(mglPoint(0.8,-0.3), "P", "w:C", -1.4);
3386 	//#cmywp
3387 	gr->FaceZ(mglPoint(-1,	-0.1), 0.4, 0.3, "c#");	gr->Puts(mglPoint(-0.8, 0), "c", "k:C", -1.4);
3388 	gr->FaceZ(mglPoint(-0.6,-0.1), 0.4, 0.3, "m#");	gr->Puts(mglPoint(-0.4, 0), "m", "k:C", -1.4);
3389 	gr->FaceZ(mglPoint(-0.2,-0.1), 0.4, 0.3, "y#");	gr->Puts(mglPoint(0,   0), "y", "k:C", -1.4);
3390 	gr->FaceZ(mglPoint(0.2,	-0.1), 0.4, 0.3, "w#");	gr->Puts(mglPoint(0.4, 0), "w", "k:C", -1.4);
3391 	gr->FaceZ(mglPoint(0.6,	-0.1), 0.4, 0.3, "p#");	gr->Puts(mglPoint(0.8, 0), "p", "k:C", -1.4);
3392 	//#BGRHW
3393 	gr->FaceZ(mglPoint(-1,	0.2), 0.4, 0.3, "B#");	gr->Puts(mglPoint(-0.8, 0.3), "B", "w:C", -1.4);
3394 	gr->FaceZ(mglPoint(-0.6,0.2), 0.4, 0.3, "G#");	gr->Puts(mglPoint(-0.4, 0.3), "G", "w:C", -1.4);
3395 	gr->FaceZ(mglPoint(-0.2,0.2), 0.4, 0.3, "R#");	gr->Puts(mglPoint(0,   0.3), "R", "w:C", -1.4);
3396 	gr->FaceZ(mglPoint(0.2,	0.2), 0.4, 0.3, "H#");	gr->Puts(mglPoint(0.4, 0.3), "H", "w:C", -1.4);
3397 	gr->FaceZ(mglPoint(0.6,	0.2), 0.4, 0.3, "W#");	gr->Puts(mglPoint(0.8, 0.3), "W", "w:C", -1.4);
3398 	//#bgrhw
3399 	gr->FaceZ(mglPoint(-1,	0.5), 0.4, 0.3, "b#");	gr->Puts(mglPoint(-0.8, 0.6), "b", "k:C", -1.4);
3400 	gr->FaceZ(mglPoint(-0.6,0.5), 0.4, 0.3, "g#");	gr->Puts(mglPoint(-0.4, 0.6), "g", "k:C", -1.4);
3401 	gr->FaceZ(mglPoint(-0.2,0.5), 0.4, 0.3, "r#");	gr->Puts(mglPoint(0,   0.6), "r", "k:C", -1.4);
3402 	gr->FaceZ(mglPoint(0.2,	0.5), 0.4, 0.3, "h#");	gr->Puts(mglPoint(0.4, 0.6), "h", "k:C", -1.4);
3403 	gr->FaceZ(mglPoint(0.6,	0.5), 0.4, 0.3, "w#");	gr->Puts(mglPoint(0.8, 0.6), "w", "k:C", -1.4);
3404 	//#brighted
3405 	gr->FaceZ(mglPoint(-1,	0.8), 0.4, 0.3, "{r1}#");	gr->Puts(mglPoint(-0.8, 0.9), "\\{r1\\}", "w:C", -1.4);
3406 	gr->FaceZ(mglPoint(-0.6,0.8), 0.4, 0.3, "{r3}#");	gr->Puts(mglPoint(-0.4, 0.9), "\\{r3\\}", "w:C", -1.4);
3407 	gr->FaceZ(mglPoint(-0.2,0.8), 0.4, 0.3, "{r5}#");	gr->Puts(mglPoint(0,   0.9), "\\{r5\\}", "k:C", -1.4);
3408 	gr->FaceZ(mglPoint(0.2,	0.8), 0.4, 0.3, "{r7}#");	gr->Puts(mglPoint(0.4, 0.9), "\\{r7\\}", "k:C", -1.4);
3409 	gr->FaceZ(mglPoint(0.6,	0.8), 0.4, 0.3, "{r9}#");	gr->Puts(mglPoint(0.8, 0.9), "\\{r9\\}", "k:C", -1.4);
3410 	// HEX
3411 	gr->FaceZ(mglPoint(-1, -1.3), 1, 0.3, "{xff9966}#");	gr->Puts(mglPoint(-0.5,-1.2), "\\{xff9966\\}", "k:C", -1.4);
3412 	gr->FaceZ(mglPoint(0,  -1.3), 1, 0.3, "{x83CAFF}#");	gr->Puts(mglPoint( 0.5,-1.2), "\\{x83CAFF\\}", "k:C", -1.4);
3413 
3414 	gr->SubPlot(3,2,3);
3415 	char stl[3]="r1", txt[4]="'1'";
3416 	for(int i=0;i<10;i++)
3417 	{
3418 		txt[1]=stl[1]='0'+i;
3419 		gr->Line(mglPoint(-1,0.2*i-1),mglPoint(1,0.2*i-1),stl);
3420 		gr->Puts(mglPoint(1.05,0.2*i-1),txt,":L");
3421 	}
3422 
3423 	gr->SubPlot(3,2,4);	gr->Title("TriPlot sample");	gr->Rotate(50,60);
3424 	double t[] = {0,1,2, 0,1,3, 0,2,3, 1,2,3};
3425 	double xt[] = {-1,1,0,0}, yt[] = {-1,-1,1,0}, zt[] = {-1,-1,-1,1};
3426 	mglData tt(4,3,t), uu(4,xt), vv(4,yt), ww(4,zt);
3427 	gr->TriPlot(tt,uu,vv,ww,"b");
3428 	gr->TriPlot(tt,uu,vv,ww,"k#");
3429 
3430 	gr->SubPlot(3,2,5);
3431 	mglData r(4);	r.Fill(1,4);
3432 	gr->SetRanges(1,4,1,4);	gr->Axis();
3433 	gr->Mark(r,r,"s");
3434 	gr->Plot(r,"b");
3435 }
3436 //-----------------------------------------------------------------------------
3437 const char *mmgl_minmax="define $p 30\n"
3438 "new h 300 300 '-sqrt(1-x^2-y^2)*(3*x*y^2*$p-x^3*$p+6*y)/(3*sqrt(2))+x*y+(y^2+x^2)*$p/3 -7*(y^2+x^2)^2*$p/24+y^2+3*x^2'\n"
3439 "\nminmax e h\nsubplot 1 1 0 '':title 'MinMax sample'\ncrange h:dens h:box\n"
3440 "fplot 'sin(2*pi*t)' 'cos(2*pi*t)' '0' 'k'\nplot e(0)*2-1 e(1)*2-1 '. c'";
smgl_minmax(mglGraph * gr)3441 void smgl_minmax(mglGraph *gr)	// test minmax
3442 {
3443 	mglData h(300,300);
3444 	gr->Fill(h,"-sqrt(1-x^2-y^2)*(3*x*y^2*30-x^3*30+6*y)/(3*sqrt(2))+x*y+(y^2+x^2)*10 -7*(y^2+x^2)^2*30/24+y^2+3*x^2");
3445 	mglData e=h.MinMax();
3446 	if(big!=3)	{	gr->SubPlot(1,1,0,"");	gr->Title("MinMax sample");	}
3447 	gr->SetRange('c',h);	gr->Dens(h);	gr->Box();
3448 	gr->FPlot("sin(2*pi*t)","cos(2*pi*t)","0","k");
3449 	e*=2;	e-=1;
3450 	gr->Plot(e(0),e(1),". c");
3451 }
3452 //-----------------------------------------------------------------------------
3453 const char *mmgl_conts="new a 10 10 'sin(2*pi*x*y)'\ntitle 'Conts sample':rotate 40 60:box\n"
3454 "dens a '#'\ncont [0,0] a 'r'\nconts r 0 a\nplot 2*r(0)-1 2*r(1)-1 1+r(2) '2c'";
smgl_conts(mglGraph * gr)3455 void smgl_conts(mglGraph *gr)	// test conts
3456 {
3457 	mglData a(10,10);	gr->Fill(a,"sin(2*pi*x*y)");
3458 	mglData v, r=a.Conts(0);
3459 	if(big!=3)	{	gr->Title("Conts sample");	}
3460 	gr->Rotate(40,60);	gr->Box();
3461 	gr->Dens(a,"#");	gr->Cont(v,a,"r");
3462 	mglData x(r.ny),y(r.ny),z(r.ny);
3463 	for(long i=0;i<x.nx;i++)	{	x[i]=r[r.nx*i]*2-1;	y[i]=r[r.nx*i+1]*2-1;	z[i]=1;	}
3464 	gr->Plot(x,y,z,"2c");
3465 }
3466 //-----------------------------------------------------------------------------
3467 const char *mmgl_fexport=all_prims_str
3468 "write 'fexport.jpg':#write 'fexport.png'\nwrite 'fexport.bmp':write 'fexport.tga'\n"
3469 "write 'fexport.eps':write 'fexport.svg'\nwrite 'fexport.gif':write 'fexport.xyz'\n"
3470 "write 'fexport.stl':write 'fexport.off'\nwrite 'fexport.tex':write 'fexport.obj'\n"
3471 "write 'fexport.prc':write 'fexport.json'\nwrite 'fexport.mgld'";
smgl_fexport(mglGraph * gr)3472 void smgl_fexport(mglGraph *gr)	// test file export
3473 {
3474 	all_prims(gr);
3475 	gr->WriteJPEG("fexport.jpg");
3476 //	gr->WritePNG("fexport.png");
3477 	gr->WriteBMP("fexport.bmp");
3478 	gr->WriteTGA("fexport.tga");
3479 	gr->WriteEPS("fexport.eps");
3480 	gr->WriteSVG("fexport.svg");
3481 	gr->WriteGIF("fexport.gif");
3482 
3483 	gr->WriteXYZ("fexport.xyz");
3484 	gr->WriteSTL("fexport.stl");
3485 	gr->WriteOFF("fexport.off");
3486 	gr->WriteTEX("fexport.tex");
3487 	gr->WriteOBJ("fexport.obj");
3488 	gr->WritePRC("fexport.prc");
3489 	gr->WriteJSON("fexport.json");
3490 
3491 	gr->ExportMGLD("fexport.mgld");
3492 	gr->Clf();
3493 	gr->ImportMGLD("fexport.mgld");
3494 }
3495 //-----------------------------------------------------------------------------
3496 const char *mmgl_quality0="quality 0\n"
3497 all_prims_str;
smgl_quality0(mglGraph * gr)3498 void smgl_quality0(mglGraph *gr)	// test file export
3499 {
3500 	gr->SetQuality(0);	all_prims(gr);
3501 }
3502 //-----------------------------------------------------------------------------
3503 const char *mmgl_quality1="quality 1\n"
3504 all_prims_str;
smgl_quality1(mglGraph * gr)3505 void smgl_quality1(mglGraph *gr)	// test file export
3506 {
3507 	gr->SetQuality(1);	all_prims(gr);
3508 }
3509 //-----------------------------------------------------------------------------
3510 const char *mmgl_quality2="quality 2\n"
3511 all_prims_str;
smgl_quality2(mglGraph * gr)3512 void smgl_quality2(mglGraph *gr)	// test file export
3513 {
3514 	gr->SetQuality(2);	all_prims(gr);
3515 }
3516 //-----------------------------------------------------------------------------
3517 const char *mmgl_quality4="quality 4\n"
3518 all_prims_str;
smgl_quality4(mglGraph * gr)3519 void smgl_quality4(mglGraph *gr)	// test file export
3520 {
3521 	gr->SetQuality(4);	all_prims(gr);
3522 }
3523 //-----------------------------------------------------------------------------
3524 const char *mmgl_quality5="quality 5\n"
3525 all_prims_str;
smgl_quality5(mglGraph * gr)3526 void smgl_quality5(mglGraph *gr)	// test file export
3527 {
3528 	gr->SetQuality(5);	all_prims(gr);
3529 }
3530 //-----------------------------------------------------------------------------
3531 const char *mmgl_quality6="quality 6\n"
3532 all_prims_str;
smgl_quality6(mglGraph * gr)3533 void smgl_quality6(mglGraph *gr)	// test file export
3534 {
3535 	gr->SetQuality(6);	all_prims(gr);
3536 }
3537 //-----------------------------------------------------------------------------
3538 const char *mmgl_quality8="quality 8\n"
3539 all_prims_str;
smgl_quality8(mglGraph * gr)3540 void smgl_quality8(mglGraph *gr)	// test file export
3541 {
3542 	gr->SetQuality(8);	all_prims(gr);
3543 }
3544 //-----------------------------------------------------------------------------
3545 //-----------------------------------------------------------------------------
3546 mglSample samp[] = {
3547 	{"3wave", smgl_3wave, mmgl_3wave, "Example of complex @ref{ode} on basis of 3-wave decay."},
3548 	{"alpha", smgl_alpha, mmgl_alpha, "Example of @ref{light} and @ref{alpha} (transparency)."},
3549 	{"apde", smgl_apde, mmgl_apde,  "Comparison of advanced PDE solver (@ref{apde}) and ordinary one (@ref{pde})."},
3550 	{"area", smgl_area, mmgl_area, "Function @ref{area} fill the area between curve and axis plane. It support gradient filling if 2 colors per curve is specified."},
3551 	{"aspect", smgl_aspect, mmgl_aspect, "Example of @ref{subplot}, @ref{inplot}, @ref{rotate}, @ref{aspect}, @ref{shear}."},
3552 	{"axial", smgl_axial, mmgl_axial, "Function @ref{axial} draw surfaces of rotation for contour lines. You can draw wire surfaces (@samp{#} style) or ones rotated in other directions (@samp{x}, @samp{z} styles)."},
3553 	{"axis", smgl_axis, mmgl_axis, "Different forms of @ref{axis} position."},
3554 	{"background", smgl_background, mmgl_background, "Load @ref{background} from an image file."},
3555 	{"barh", smgl_barh, mmgl_barh, "Function @ref{barh} is the similar to @ref{bars} but draw horizontal bars."},
3556 	{"bars", smgl_bars, mmgl_bars, "Function @ref{bars} draw vertical bars. It have a lot of options: bar-above-bar (@samp{a} style), fall like (@samp{f} style), 2 colors for positive and negative values, wired bars (@samp{#} style), 3D variant."},
3557 	{"belt", smgl_belt, mmgl_belt, "Function @ref{belt} draw surface by belts. You can use @samp{x} style for drawing lines in other direction."},
3558 	{"beltc", smgl_beltc, mmgl_beltc, "Function @ref{beltc} draw surface by belts. You can use @samp{x} style for drawing lines in other direction."},
3559 	{"bifurcation", smgl_bifurcation, mmgl_bifurcation, "Function @ref{bifurcation} draw Bifurcation diagram for multiple stationary points of the map (like logistic map)."},
3560 	{"box", smgl_box, mmgl_box, "Different styles of bounding @ref{box}."},
3561 	{"boxplot", smgl_boxplot, mmgl_boxplot, "Function @ref{boxplot} draw box-and-whisker diagram."},
3562 	{"boxs", smgl_boxs, mmgl_boxs, "Function @ref{boxs} draw surface by boxes. You can use @samp{#} for drawing wire plot."},
3563 	{"candle", smgl_candle, mmgl_candle, "Function @ref{candle} draw candlestick chart. This is a combination of a line-chart and a bar-chart, in that each bar represents the range of price movement over a given time interval."},
3564 	{"chart", smgl_chart, mmgl_chart, "Function @ref{chart} draw colored boxes with width proportional to data values. Use @samp{ } for empty box. It produce well known pie chart if drawn in polar coordinates."},
3565 	{"cloud", smgl_cloud, mmgl_cloud , "Function @ref{cloud} draw cloud-like object which is less transparent for higher data values. Similar plot can be created using many (about 10...20 -- @code{surf3a a a;value 10}) isosurfaces @ref{surf3a}."},
3566 	{"colorbar", smgl_colorbar, mmgl_colorbar, "Example of @ref{colorbar} position and styles."},
3567 	{"combined", smgl_combined, mmgl_combined , "Example of several plots in the same axis."},
3568 	{"cones", smgl_cones, mmgl_cones, "Function @ref{cones} is similar to @ref{bars} but draw cones."},
3569 	{"cont", smgl_cont, mmgl_cont, "Function @ref{cont} draw contour lines for surface. You can select automatic (default) or manual levels for contours, print contour labels, draw it on the surface (default) or at plane (as @code{Dens})."},
3570 	{"cont3", smgl_cont3, mmgl_cont3, "Function @ref{contf3} draw ordinary contour lines but at slices of 3D data. "},
3571 	{"cont_xyz", smgl_cont_xyz, mmgl_cont_xyz, "Functions @ref{contz}, @ref{conty}, @ref{contx} draw contour lines on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field."},
3572 	{"contd", smgl_contd, mmgl_contd, "Function @ref{contd} is similar to @ref{contf} but with manual contour colors."},
3573 	{"contf", smgl_contf, mmgl_contf, "Function @ref{contf} draw filled contours.  You can select automatic (default) or manual levels for contours."},
3574 	{"contf3", smgl_contf3, mmgl_contf3, "Function @ref{contf3} draw ordinary filled contours but at slices of 3D data. "},
3575 	{"contf_xyz", smgl_contf_xyz, mmgl_contf_xyz, "Functions @ref{contfz}, @ref{contfy}, @ref{contfx}, draw filled contours on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field."},
3576 	{"conts", smgl_conts, mmgl_conts, "Function @ref{conts} get contour coordinate as data array."},
3577 	{"contv", smgl_contv, mmgl_contv, "Function @ref{contv} draw vertical cylinders (belts) at contour lines."},
3578 	{"correl", smgl_correl, mmgl_correl, "Test of correlation function (@ref{correl})."},
3579 //	{"crust", smgl_crust, mmgl_crust, ""},	// TODO: open after triangulation
3580 	{"curvcoor", smgl_curvcoor, mmgl_curvcoor, "Some common curvilinear coordinates."},
3581 	{"cut", smgl_cut, mmgl_cut, "Example of point cutting (@ref{cut}."},
3582 	{"daisy", smgl_daisy, mmgl_daisy, "Example of subfunctions and summation in textual formulas."},
3583 	{"dat_diff", smgl_dat_diff, mmgl_dat_diff, "Example of @ref{diff} and @ref{integrate}."},
3584 	{"dat_extra", smgl_dat_extra, mmgl_dat_extra , "Example of @ref{envelop}, @ref{sew}, @ref{smooth} and @ref{resize}."},
3585 	{"data1", smgl_data1, mmgl_data1, ""},
3586 	{"data2", smgl_data2, mmgl_data2, ""},
3587 	{"dcont", smgl_dcont, mmgl_dcont, "Function @ref{dcont} draw lines of intersections of two isosurfaces."},
3588 	{"dens", smgl_dens, mmgl_dens, "Function @ref{dens} draw density plot (also known as color-map) for surface."},
3589 	{"dens3", smgl_dens3, mmgl_dens3, "Function @ref{dens3} draw ordinary density plots but at slices of 3D data."},
3590 	{"dens_xyz", smgl_dens_xyz, mmgl_dens_xyz, "Functions @ref{densz}, @ref{densy}, @ref{densx} draw density plot on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field."},
3591 	{"detect", smgl_detect, mmgl_detect, "Example of curve @ref{detect}."},
3592 	{"dew", smgl_dew, mmgl_dew, "Function @ref{dew} is similar to @ref{vect} but use drops instead of arrows."},
3593 	{"diffract", smgl_diffract, mmgl_diffract, ""},
3594 	{"dilate", smgl_dilate, mmgl_dilate, "Example of @ref{dilate} and @ref{erode}."},
3595 	{"dots", smgl_dots, mmgl_dots, "Function @ref{dots} is another way to draw irregular points. @code{Dots} use color scheme for coloring (see @ref{Color scheme})."},
3596 	{"earth", smgl_earth, mmgl_earth, "Example of Earth map by using @ref{import}."},
3597 	{"error", smgl_error, mmgl_error, "Function @ref{error} draw error boxes around the points. You can draw default boxes or semi-transparent symbol (like marker, see @ref{Line styles}). Also you can set individual color for each box. See also @ref{error2 sample}."},
3598 	{"error2", smgl_error2, mmgl_error2, "Example of @ref{error} kinds."},
3599 	{"export", smgl_export, mmgl_export, "Example of data @ref{export} and @ref{import}."},
3600 	{"fall", smgl_fall, mmgl_fall, "Function @ref{fall} draw waterfall surface. You can use @ref{meshnum} for changing number of lines to be drawn. Also you can use @samp{x} style for drawing lines in other direction."},
3601 	{"fexport", smgl_fexport, mmgl_fexport, "Example of @ref{write} to different file formats."},
3602 	{"fit", smgl_fit, mmgl_fit, "Example of nonlinear @ref{fit}."},
3603 	{"flame2d", smgl_flame2d, mmgl_flame2d, "Function @ref{flame2d} generate points for flame fractals in 2d case."},
3604 	{"flow", smgl_flow, mmgl_flow, "Function @ref{flow} is another standard way to visualize vector fields -- it draw lines (threads) which is tangent to local vector field direction. MathGL draw threads from edges of bounding box and from central slices. Sometimes it is not most appropriate variant -- you may want to use @code{flowp} to specify manual position of threads. The color scheme is used for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source)."}, // TODO @ref{flowp}
3605 	{"flow3", smgl_flow3, mmgl_flow3, "Function @ref{flow3} draw flow threads, which start from given plane."},
3606 	{"fog", smgl_fog, mmgl_fog, "Example of @ref{fog}."},
3607 	{"fonts", smgl_fonts, mmgl_fonts, "Example of @ref{font} typefaces."},
3608 	{"grad", smgl_grad, mmgl_grad, "Function @ref{grad} draw gradient lines for matrix."},
3609 	{"hist", smgl_hist, mmgl_hist, "Example of @ref{hist} (histogram)."},
3610 	{"icon", smgl_icon, mmgl_icon, "Default UDAV and mgllab icon."},
3611 	{"ifs2d", smgl_ifs2d, mmgl_ifs2d, "Function @ref{ifs2d} generate points for fractals using iterated function system in 2d case."},
3612 	{"ifs3d", smgl_ifs3d, mmgl_ifs3d, "Function @ref{ifs3d} generate points for fractals using iterated function system in 3d case."},
3613 	{"indirect",smgl_indirect,mmgl_indirect, "Comparison of @ref{subdata} vs @ref{evaluate}/"},
3614 	{"inplot", smgl_inplot, mmgl_inplot, "Example of @ref{inplot}, @ref{multiplot}, @ref{columnplot}, @ref{gridplot}, @ref{shearplot}, @ref{stickplot}."},
3615 	{"iris", smgl_iris, mmgl_iris, "Function @ref{iris} draw Iris plot for columns of data array."},
3616 	{"keep", smgl_keep, mmgl_keep, "Function @ref{keep} conserve initial phase along specified direction(s)."},
3617 	{"label", smgl_label, mmgl_label, "Function @ref{label} print text at data points. The string may contain @samp{%x}, @samp{%y}, @samp{%z} for x-, y-, z-coordinates of points, @samp{%n} for point index."},
3618 	{"lamerey", smgl_lamerey, mmgl_lamerey, "Function @ref{lamerey} draw Lamerey diagram."},
3619 	{"legend", smgl_legend, mmgl_legend , "Example of @ref{legend} styles."},
3620 	{"light", smgl_light, mmgl_light, "Example of @ref{light} with different types."},
3621 	{"lines", smgl_lines, mmgl_lines, "Function @ref{lines} draw a set of lines."},
3622 	{"loglog", smgl_loglog, mmgl_loglog, "Example of log- and log-log- axis labels."},
3623 	{"map", smgl_map, mmgl_map, "Example of @ref{map}."},
3624 	{"mark", smgl_mark, mmgl_mark, "Example of @ref{mark}."},
3625 	{"mask", smgl_mask, mmgl_mask, "Example of @ref{mask} kinds."},
3626 	{"mesh", smgl_mesh, mmgl_mesh, "Function @ref{mesh} draw wired surface. You can use @ref{meshnum} for changing number of lines to be drawn."},
3627 	{"minmax", smgl_minmax, mmgl_minmax, "Function @ref{minmax} get position of local minimums and maximums."},
3628 	{"mirror", smgl_mirror, mmgl_mirror , "Example of using options."},
3629 	{"molecule", smgl_molecule, mmgl_molecule , "Example of drawing molecules."},
3630 	{"ode", smgl_ode, mmgl_ode, "Example of phase plain created by @ref{ode} solving, contour lines (@ref{cont}) and @ref{flow} threads."},
3631 	{"ohlc", smgl_ohlc, mmgl_ohlc, "Function @ref{ohlc} draw Open-High-Low-Close diagram. This diagram show vertical line for between maximal(high) and minimal(low) values, as well as horizontal lines before/after vertical line for initial(open)/final(close) values of some process."},
3632 	{"param1", smgl_param1, mmgl_param1, "Example of parametric plots for 1D data."},
3633 	{"param2", smgl_param2, mmgl_param2, "Example of parametric plots for 2D data."},
3634 	{"param3", smgl_param3, mmgl_param3, "Example of parametric plots for 3D data."},
3635 	{"paramv", smgl_paramv, mmgl_paramv, "Example of parametric plots for vector fields."},
3636 	{"parser", smgl_parser, mmgl_parser, "Basic MGL script."},
3637 	{"pde", smgl_pde, mmgl_pde, "Example of @ref{pde} solver."},
3638 	{"pendelta", smgl_pendelta, mmgl_pendelta, "Example of @ref{pendelta} for lines and glyphs smoothing."},
3639 	{"pipe", smgl_pipe, mmgl_pipe, "Function @ref{pipe} is similar to @ref{flow} but draw pipes (tubes) which radius is proportional to the amplitude of vector field. The color scheme is used for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source)."},
3640 	{"plot", smgl_plot, mmgl_plot, "Function @ref{plot} is most standard way to visualize 1D data array. By default, @code{Plot} use colors from palette. However, you can specify manual color/palette, and even set to use new color for each points by using @samp{!} style. Another feature is @samp{ } style which draw only markers without line between points."},
3641 	{"pmap", smgl_pmap, mmgl_pmap, "Function @ref{pmap} draw Poincare map -- show intersections of the curve and the surface."},
3642 	{"primitives", smgl_primitives, mmgl_primitives , "Example of primitives: @ref{line}, @ref{curve}, @ref{rhomb}, @ref{ellipse}, @ref{face}, @ref{sphere}, @ref{drop}, @ref{cone}."},
3643 	{"projection", smgl_projection, mmgl_projection , "Example of plot projection (@ref{ternary}=4)."},
3644 	{"projection5", smgl_projection5, mmgl_projection5 , "Example of plot projection in ternary coordinates (@ref{ternary}=5)."},
3645 	{"pulse", smgl_pulse, mmgl_pulse , "Example of @ref{pulse} parameter determining."},
3646 	{"qo2d", smgl_qo2d, mmgl_qo2d, "Example of PDE solving by quasioptical approach @ref{qo2d}."},
3647 	{"quality0", smgl_quality0, mmgl_quality0, "Show all kind of primitives in @ref{quality}=0."},
3648 	{"quality1", smgl_quality1, mmgl_quality1, "Show all kind of primitives in @ref{quality}=1."},
3649 	{"quality2", smgl_quality2, mmgl_quality2, "Show all kind of primitives in @ref{quality}=2."},
3650 	{"quality4", smgl_quality4, mmgl_quality4, "Show all kind of primitives in @ref{quality}=4."},
3651 	{"quality5", smgl_quality5, mmgl_quality5, "Show all kind of primitives in @ref{quality}=5."},
3652 	{"quality6", smgl_quality6, mmgl_quality6, "Show all kind of primitives in @ref{quality}=6."},
3653 	{"quality8", smgl_quality8, mmgl_quality8, "Show all kind of primitives in @ref{quality}=8."},
3654 	{"radar", smgl_radar, mmgl_radar, "The @ref{radar} plot is variant of @ref{plot}, which make plot in polar coordinates and draw radial rays in point directions. If you just need a plot in polar coordinates then I recommend to use @ref{Curvilinear coordinates} or @ref{plot} in parametric form with @code{x=r*cos(fi); y=r*sin(fi);}."},
3655 	{"refill", smgl_refill, mmgl_refill, "Example of @ref{refill} and @ref{gspline}."},
3656 	{"region", smgl_region, mmgl_region, "Function @ref{region} fill the area between 2 curves. It support gradient filling if 2 colors per curve is specified. Also it can fill only the region y1<y<y2 if style @samp{i} is used."},
3657 	{"scanfile", smgl_scanfile, mmgl_scanfile , "Example of @ref{scanfile} for reading 'named' data."},
3658 	{"schemes", smgl_schemes, mmgl_schemes , "Example of popular color schemes."},
3659 	{"section", smgl_section, mmgl_section, "Example of @ref{section} to separate data and @ref{join} it back."},
3660 	{"several_light", smgl_several_light, mmgl_several_light , "Example of using several @ref{light} sources."},
3661 	{"solve", smgl_solve, mmgl_solve, "Example of @ref{solve} for root finding."},
3662 	{"stem", smgl_stem, mmgl_stem, "Function @ref{stem} draw vertical bars. It is most attractive if markers are drawn too."},
3663 	{"step", smgl_step, mmgl_step, "Function @ref{step} plot data as stairs. At this stairs can be centered if sizes are differ by 1."},
3664 	{"stereo", smgl_stereo, mmgl_stereo, "Example of stereo image of @ref{surf}."},
3665 	{"stfa", smgl_stfa, mmgl_stfa, "Example of @ref{stfa}."},
3666 	{"style", smgl_style, mmgl_style , "Example of colors and styles for plots."},
3667 	{"surf", smgl_surf, mmgl_surf, "Function @ref{surf} is most standard way to visualize 2D data array. @code{Surf} use color scheme for coloring (see @ref{Color scheme}). You can use @samp{#} style for drawing black meshes on the surface."},
3668 	{"surf3", smgl_surf3, mmgl_surf3, "Function @ref{surf3} is one of most suitable (for my opinion) functions to visualize 3D data. It draw the isosurface(s) -- surface(s) of constant amplitude (3D analogue of contour lines). You can draw wired isosurfaces if specify @samp{#} style."},
3669 	{"surf3a", smgl_surf3a, mmgl_surf3a, "Function @ref{surf3c} is similar to @ref{surf3} but its transparency is determined by another data."},
3670 	{"surf3c", smgl_surf3c, mmgl_surf3c, "Function @ref{surf3c} is similar to @ref{surf3} but its coloring is determined by another data."},
3671 	{"surf3ca", smgl_surf3ca, mmgl_surf3ca, "Function @ref{surf3c} is similar to @ref{surf3} but its coloring and transparency is determined by another data arrays."},
3672 	{"surfa", smgl_surfa, mmgl_surfa, "Function @ref{surfa} is similar to @ref{surf} but its transparency is determined by another data."},
3673 	{"surfc", smgl_surfc, mmgl_surfc, "Function @ref{surfc} is similar to @ref{surf} but its coloring is determined by another data."},
3674 	{"surfca", smgl_surfca, mmgl_surfca, "Function @ref{surfca} is similar to @ref{surf} but its coloring and transparency is determined by another data arrays."},
3675 	{"table", smgl_table, mmgl_table, "Function @ref{table} draw table with data values."},
3676 	{"tape", smgl_tape, mmgl_tape, "Function @ref{tape} draw tapes which rotate around the curve as transverse orts of accompanied coordinates."},
3677 	{"tens", smgl_tens, mmgl_tens, "Function @ref{tens} is variant of @ref{plot} with smooth coloring along the curves. At this, color is determined as for surfaces (see @ref{Color scheme})."},
3678 	{"ternary", smgl_ternary, mmgl_ternary , "Example of @ref{ternary} coordinates."},
3679 	{"text", smgl_text, mmgl_text, "Example of @ref{text} possibilities."},
3680 	{"text2", smgl_text2, mmgl_text2, "Example of @ref{text} along curve."},
3681 	{"textmark", smgl_textmark, mmgl_textmark, "Function @ref{textmark} is similar to @ref{mark} but draw text instead of markers."},
3682 	{"ticks", smgl_ticks, mmgl_ticks, "Example of @ref{axis} ticks."},
3683 	{"tile", smgl_tile, mmgl_tile, "Function @ref{tile} draw surface by tiles."},
3684 	{"tiles", smgl_tiles, mmgl_tiles, "Function @ref{tiles} is similar to @ref{tile} but tile sizes is determined by another data. This allows one to simulate transparency of the plot."},
3685 	{"torus", smgl_torus, mmgl_torus , "Function @ref{torus} draw surface of the curve rotation."},
3686 	{"traj", smgl_traj, mmgl_traj, "Function @ref{traj} is 1D analogue of @ref{vect}. It draw vectors from specified points."},
3687 	{"triangulation",smgl_triangulation, mmgl_triangulation , "Example of use @ref{triangulate} for arbitrary placed points."},
3688 	{"triplot", smgl_triplot, mmgl_triplot, "Functions @ref{triplot} and @ref{quadplot} draw set of triangles (or quadrangles, correspondingly) for irregular data arrays. Note, that you have to provide not only vertexes, but also the indexes of triangles or quadrangles. I.e. perform triangulation by some other library. See also @ref{triangulate}."},
3689 	{"tube", smgl_tube, mmgl_tube, "Function @ref{tube} draw tube with variable radius."},
3690 	{"type0", smgl_type0, mmgl_type0, "Example of ordinary transparency (@ref{transptype}=0)."},
3691 	{"type1", smgl_type1, mmgl_type1, "Example of glass-like transparency (@ref{transptype}=1)."},
3692 	{"type2", smgl_type2, mmgl_type2, "Example of lamp-like transparency (@ref{transptype}=2)."},
3693 	{"vect", smgl_vect, mmgl_vect, "Function @ref{vect} is most standard way to visualize vector fields -- it draw a lot of arrows or hachures for each data cell. It have a lot of options which can be seen on the figure (and in the sample code), and use color scheme for coloring (see @ref{Color scheme})."},
3694 	{"vect3", smgl_vect3, mmgl_vect3, "Function @ref{vect3} draw ordinary vector field plot but at slices of 3D data."},
3695 	{"venn", smgl_venn, mmgl_venn, "Example of venn-like diagram."},
3696 {"", NULL, NULL, NULL}};
3697 //-----------------------------------------------------------------------------
3698