| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
9.4.17 Flow 3D sample
C++ code
mglData ex(30,30,30), ey(30,30,30), ez(30,30,30);
ex.Fill("0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ey.Fill("0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
ez.Fill("0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)", gr->Min, gr->Max);
gr->Rotate(40,60);
gr->Box();
gr->Flow(ex, ey, ez, "bwr");
MGL code
new ex 30 30 30 new ey 30 30 30 new ez 30 30 30 fill ex '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)' fill ey '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)' fill ez '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - 0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)' rotate 40 60 box flow ex ey ez 'bwr'
Pure C code
HMDT ex, ey, ez;
ex = mgl_create_data_size(30,30,30);
ey = mgl_create_data_size(30,30,30);
ez = mgl_create_data_size(30,30,30);
mgl_data_fill_eq(gr, ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_data_fill_eq(gr, ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)",0,0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
mgl_flow_3d(gr,ex,ey,ez,"bwr",3,1);
mgl_delete_data(ex); mgl_delete_data(ey); mgl_delete_data(ez);
Fortran code
integer ex,ey,ez, mgl_create_data_size
ex = mgl_create_data_size(30,30,30)
ey = mgl_create_data_size(30,30,30)
ez = mgl_create_data_size(30,30,30)
call mgl_data_fill_eq(gr, ex, '0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - &
0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ey, '0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - &
0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_data_fill_eq(gr, ez, '0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - &
0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)',0,0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1);
call mgl_flow_3d(gr,ex,ey,ez,'bwr',3,1)
call mgl_delete_data(ex)
call mgl_delete_data(ey)
call mgl_delete_data(ez)
Python
ex, ey, ez = mglData(10,10,10), mglData(10,10,10), mglData(10,10,10);
gr.Fill(ex, "0.2*x/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*x/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ey, "0.2*y/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*y/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Fill(ez, "0.2*(z-0.3)/pow(x^2+y^2+(z-0.3)^2,1.5) - \
0.2*(z+0.3)/pow(x^2+y^2+(z+0.3)^2,1.5)");
gr.Rotate(40,60); gr.Box();
gr.Flow(ex,ey,ez,"bwr");
