Example of plot projection (ternary=4).
MGL code:
ranges 0 1 0 1 0 1 new x 50 '0.25*(1+cos(2*pi*x))' new y 50 '0.25*(1+sin(2*pi*x))' new z 50 'x' new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx light on title 'Projection sample':ternary 4:rotate 50 60 box:axis:grid plot x y z 'r2':surf a '#' xlabel 'X':ylabel 'Y':zlabel 'Z'
C++ code:
void smgl_projection(mglGraph *gr) // flag # { gr->SetRanges(0,1,0,1,0,1); mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30); a.Modify("30*x*y*(1-x-y)^2*(x+y<1)"); x.Modify("0.25*(1+cos(2*pi*x))"); y.Modify("0.25*(1+sin(2*pi*x))"); rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); z.Modify("x"); if(big!=3) gr->Title("Projection sample"); gr->Ternary(4); gr->Rotate(50,60); gr->Light(true); gr->Plot(x,y,z,"r2"); gr->Surf(a,"#"); gr->Axis(); gr->Grid(); gr->Box(); gr->Label('x',"X",1); gr->Label('y',"Y",1); gr->Label('z',"Z",1); }