manpagez: man pages & more
info mathgl
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.7.1 Curvelinear coorinates sample

../png/sample3

C++ code

gr->Org = mglPoint(-1,1,-1);
gr->SubPlot(2,2,0); gr->Rotate(60,40);
gr->Line(mglPoint(-1,0.5,0),mglPoint(1,0.5,0),"r2",100);
gr->Axis(); gr->Grid();
gr->Text(mglPoint(0,1.3,1),"Cartesian");
gr->SubPlot(2,2,1); gr->Rotate(60,40);
gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)");
gr->Line(mglPoint(-1,0.5,0),mglPoint(1,0.5,0),"r2",100);
gr->Axis(); gr->Grid();
gr->Text(mglPoint(0,1.3,1),"Cylindrical");
gr->SubPlot(2,2,2); gr->Rotate(60,40);
gr->SetFunc("2*y*x","y*y - x*x");
gr->Line(mglPoint(-1,0.5,0),mglPoint(1,0.5,0),"r2",100);
gr->Axis(); gr->Grid();
gr->Text(mglPoint(0,1.3,1),"Parabolic");
gr->SubPlot(2,2,3); gr->Rotate(60,40);
gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)","x+z");
gr->Line(mglPoint(-1,0.5,0),mglPoint(1,0.5,0),"r2",100);
gr->Axis(); gr->Grid();
gr->Text(mglPoint(0,1.3,1),"Spiral");
gr->Axis(0,0,0); // set to default Cartesian

MGL code

origin -1 1 -1
subplot 2 2 0
rotate 60 40
line -1 0.5 0 1 0.5 0 'r2'
axis
grid
text 0 1.3 1 'Cartesian'
subplot 2 2 1
rotate 60 40
axis 'y*sin(pi*x)' 'y*cos(pi*x)' ''
line -1 0.5 0 1 0.5 0 'r2'
axis
grid
text 0 1.3 1 'Cylindrical'
subplot 2 2 2
rotate 60 40
axis '2*y*x' 'y*y - x*x' ''
line -1 0.5 0 1 0.5 0 'r2'
axis
grid
text 0 1.3 1 'Parabolic'
subplot 2 2 3
rotate 60 40
axis 'y*sin(pi*x)' 'y*cos(pi*x)' 'x+z'
line -1 0.5 0 1 0.5 0 'r2'
axis
grid
text 0 1.3 1 'Spiral'
axis '' '' '' # set to default Cartesian

Pure C code

mgl_set_origin(gr,-1,1,-1);
mgl_subplot(gr,2,2,0); mgl_rotate(gr,60,40,0);
mgl_line(gr,-1,0.5,0,1,0.5,0,"r2",100);
mgl_axis(gr,"xyz"); mgl_axis_grid(gr,"xyz","B");
mgl_text(gr,0,1.3,1,"Cartesian");
mgl_subplot(gr,2,2,1); mgl_rotate(gr,60,40,0);
mgl_set_func(gr,"y*sin(pi*x)","y*cos(pi*x)",0);
mgl_line(gr,-1,0.5,0,1,0.5,0,"r2",100);
mgl_axis(gr,"xyz"); mgl_axis_grid(gr,"xyz","B");
mgl_text(gr,0,1.3,1,"Cylindrical");
mgl_subplot(gr,2,2,2); mgl_rotate(gr,60,40,0);
mgl_set_func(gr,"2*y*x","y*y - x*x","");
mgl_line(gr,-1,0.5,0,1,0.5,0,"r2",100);
mgl_axis(gr,"xyz"); mgl_axis_grid(gr,"xyz","B");
mgl_text(gr,0,1.3,1,"Parabolic");
mgl_subplot(gr,2,2,3); mgl_rotate(gr,60,40,0);
mgl_set_func(gr,"y*sin(pi*x)","y*cos(pi*x)","x+z");
mgl_line(gr,-1,0.5,0,1,0.5,0,"r2",100);
mgl_axis(gr,"xyz"); mgl_axis_grid(gr,"xyz","B");
mgl_text(gr,0,1.3,1,"Spiral");
mgl_set_func(gr,0,0,0); /* set to default Cartesian */

Fortran code

call mgl_set_origin(gr,-1.,1.,-1.)
call mgl_subplot(gr,2,2,0)
call mgl_rotate(gr,60.,40.,0.)
call mgl_line(gr,-1.,0.5,0.,1.,0.5,0.,'r2',100)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B')
call mgl_text(gr,0.,1.3,1.,'Cartesian')
call mgl_subplot(gr,2,2,1)
call mgl_rotate(gr,60.,40.,0.)
call mgl_set_func(gr,'y*sin(pi*x)','y*cos(pi*x)','')
call mgl_line(gr,-1.,0.5,0.,1.,0.5,0.,'r2',100)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B')
call mgl_text(gr,0.,1.3,1.,'Cylindrical')
call mgl_subplot(gr,2,2,2)
call mgl_rotate(gr,60.,40.,0.)
call mgl_set_func(gr,'2*y*x','y*y - x*x','')
call mgl_line(gr,-1.,0.5,0.,1.,0.5,0.,'r2',100)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B')
call mgl_text(gr,0.,1.3,1.,"Parabolic")
call mgl_subplot(gr,2,2,3)
call mgl_rotate(gr,60.,40.,0.)
call mgl_set_func(gr,'y*sin(pi*x)','y*cos(pi*x)','x+z')
call mgl_line(gr,-1.,0.5,0.,1.,0.5,0.,'r2',100)
call mgl_axis(gr,'xyz')
call mgl_axis_grid(gr,'xyz','B')
call mgl_text(gr,0.,1.3,1.,'Spiral')
call mgl_set_func(gr,'','','') ! set to default Cartesian

Python

gr.SetOrigin(-1,1,-1);
gr.SubPlot(2,2,0);              gr.Rotate(60,40);
gr.Line(-1,0.5,0,1,0.5,0,"r2",100);
gr.Axis();              gr.Grid();
gr.Puts(0,1.3,1,"Gartesian","rC",-1.5);
gr.SubPlot(2,2,1);  gr.Rotate(60,40);
gr.SetFunc("y*sin(pi*x)","y*cos(pi*x)");
gr.Line(-1,0.5,0,1,0.5,0,"r2",100);
gr.Axis();          gr.Grid();
gr.Puts(0,1.3,1,"Cylindrical","rC",-1.5);
gr.SubPlot(2,2,2);  gr.Rotate(60,40);
gr.SetFunc("2*y*x","y*y-x*x");
gr.Line(-1,0.5,0,1,0.5,0,"r2",100);
gr.Axis();          gr.Grid();
gr.Puts(0,1.3,1,"Parabolic","rC",-1.5);
gr.SubPlot(2,2,3);  gr.Rotate(60,40);
gr.SetFunc("y*sin(pi*x)","y*cos(pi*x)","x+z");
gr.Line(-1,0.5,0,1,0.5,0,"r2",100);
gr.Axis();          gr.Grid();
gr.Puts(0,1.3,1,"Spiral","rC",-1.5);
gr.SetFunc("","");   # set to default Gartesian

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.