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

9.6.2 Adding mesh sample

../png/samplea

C++ code

mglData a(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))");
gr->Light(true);
gr->Alpha(true);
gr->SubPlot(2,2,0); gr->Rotate(40,60);
gr->Surf(a,"BbcyrR#");  gr->Box();
gr->SubPlot(2,2,1); gr->Rotate(40,60);
gr->Dens(a,"BbcyrR#");  gr->Box();
gr->SubPlot(2,2,2); gr->Rotate(40,60);
gr->Cont(a,"BbcyrR#");  gr->Box();
gr->SubPlot(2,2,3); gr->Rotate(40,60);
gr->Axial(a,"BbcyrR#"); gr->Box();

MGL code

new a 50 40
modify a '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))'
alpha on
light on
subplot 2 2 0
rotate 40 60
surf a 'BbcyrR#'
box
subplot 2 2 1
rotate 40 60
dens a 'BbcyrR#'
box
subplot 2 2 2
rotate 40 60
cont a 'BbcyrR#'
box
subplot 2 2 3
rotate 40 60
axial a 'BbcyrR#'
box

Pure C code

HMDT a = mgl_create_data_size(50,40,1);
mgl_data_modify(a,"0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))",0);
mgl_set_alpha(gr,1);
mgl_set_light(gr,1);
mgl_subplot(gr,2,2,0); mgl_rotate(gr,40.,60.,0.);
mgl_surf(gr,a,"BbcyrR#");       mgl_box(gr,1);
mgl_subplot(gr,2,2,1); mgl_rotate(gr,40.,60.,0.);
mgl_dens(gr,a,"BbcyrR#",-1.);   mgl_box(gr,1);
mgl_subplot(gr,2,2,2); mgl_rotate(gr,40.,60.,0.);
mgl_cont(gr,a,"BbcyrR#",7,NAN); mgl_box(gr,1);
mgl_subplot(gr,2,2,3); mgl_rotate(gr,40.,60.,0.);
mgl_axial(gr,a,"BbcyrR#",3);    mgl_box(gr,1);
mgl_delete_data(a);

Fortran code

integer a, mgl_create_data_size
real zero, nan
zero=0; nan=zero/zero
a = mgl_create_data_size(50,40,1)
call mgl_data_modify(a,'0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))',0)
call mgl_set_alpha(gr,1)
call mgl_set_light(gr,1)
call mgl_subplot(gr,2,2,0)
call mgl_rotate(gr,40.,60.,0.)
call mgl_surf(gr,a,'BbcyrR#')
call mgl_box(gr,1)
call mgl_subplot(gr,2,2,1)
call mgl_rotate(gr,40.,60.,0.)
call mgl_dens(gr,a,'BbcyrR#',-1.)
call mgl_box(gr,1)
call mgl_subplot(gr,2,2,2)
call mgl_rotate(gr,40.,60.,0.)
call mgl_cont(gr,a,'BbcyrR#',7,nan)
call mgl_box(gr,1)
call mgl_subplot(gr,2,2,3)
call mgl_rotate(gr,40.,60.,0.)
call mgl_axial(gr,a,'BbcyrR#',3)
call mgl_box(gr,1)
call mgl_delete_data(a)

Python

a = mglData(50,40);
a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))");
gr.Light(True);     gr.Alpha(True);
gr.SubPlot(2,2,0);
gr.Rotate(40,60);   gr.Surf(a,"BbcyrR#");   gr.Box();
gr.SubPlot(2,2,1);
gr.Rotate(40,60);   gr.Dens(a,"BbcyrR#");   gr.Box();
gr.SubPlot(2,2,2);
gr.Rotate(40,60);   gr.Cont(a,"BbcyrR#");   gr.Box();
gr.SubPlot(2,2,3);
gr.Rotate(40,60);   gr.Axial(a,"BbcyrR#");  gr.Box();

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