Next: , Previous: , Up: 1D samples   [Contents][Index]


3.5.20 Tube sample

Function tube draw tube with variable radius. The sample code is:

int sample(mglGraph *gr)
{
  mglData y,y1,y2;  mgls_prepare1d(&y,&y1,&y2); y1/=20;
  gr->SubPlot(2,2,0,"");  gr->Title("Tube plot (default)");
  gr->Light(true);  gr->Box();  gr->Tube(y,0.05);

  gr->SubPlot(2,2,1,"");  gr->Title("variable radius");
  gr->Box();  gr->Tube(y,y1);

  gr->SubPlot(2,2,2,"");  gr->Title("'\\#' style");
  gr->Box();  gr->Tube(y,0.05,"#");
  mglData yc(50), xc(50), z(50);  z.Modify("2*x-1");
  yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");

  gr->SubPlot(2,2,3); gr->Title("3d variant");  gr->Rotate(50,60);
  gr->Box();  gr->Tube(xc,yc,z,y2,"r");
  return 0;
}

Example of Tube()