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

9.3.8 Dens projection sample

../png/dens_xyz

C++ code

mglData a(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr->Rotate(40,60);
gr->Box();
gr->DensX(a.Sum("x"),"",-1);
gr->DensY(a.Sum("y"),"",1);
gr->DensZ(a.Sum("z"),"",-1);

MGL code

new a 60 50 40
modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)'
rotate 40 60
box
sum s a 'x'
densx s '' -1
sum s a 'y'
densy s '' 1
sum s a 'z'
densz s '' -1

Pure C code

HMDT a, s; a = mgl_create_data_size(60,50,40);
mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
mgl_rotate(gr,40.,60.,0.);
mgl_box(gr,1);
s=mgl_data_sum(a,"x"); mgl_dens_x(gr,s,0,-1.); mgl_delete_data(s);
s=mgl_data_sum(a,"y"); mgl_dens_y(gr,s,0,1.); mgl_delete_data(s);
s=mgl_data_sum(a,"z"); mgl_dens_z(gr,s,0,-1.); mgl_delete_data(s);
mgl_delete_data(a);

Fortran code

integer a,s, mgl_create_data_size, mgl_data_sum
a = mgl_create_data_size(60,50,40);
call mgl_data_modify(a,"-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)",0);
call mgl_rotate(gr,40.,60.,0.)
call mgl_box(gr,1)
s=mgl_data_sum(a,'x')
call mgl_dens_x(gr,s,'',-1.)
call mgl_delete_data(s)
s=mgl_data_sum(a,'y')
call mgl_dens_y(gr,s,'',1.)
call mgl_delete_data(s)
s=mgl_data_sum(a,'z')
call mgl_dens_z(gr,s,'',-1.)
call mgl_delete_data(s)
call mgl_delete_data(a)

Python

a = mglData(60,50,40);
a.Modify("-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)");
gr.Rotate(40,60);               gr.Box();
gr.DensX(a.Sum("x"),"",-1);
gr.DensY(a.Sum("y"),"",1);
gr.DensZ(a.Sum("z"),"",-1);

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.