Next: 3D samples, Previous: 1D samples, Up: Examples [Contents][Index]
This section is devoted to visualization of 2D data arrays. 2D means the data which depend on 2 indexes (parameters) like matrix z(i,j)=z(x(i),y(j)), i=1...n, j=1...m or in parametric form {x(i,j),y(i,j),z(i,j)}. Most of samples will use the same data for plotting. So, I put its initialization in separate function
void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0)
{
register long i,j,n=50,m=40,i0;
if(a) a->Create(n,m); if(b) b->Create(n,m);
if(v) { v->Create(9); v->Fill(-1,1); }
mreal x,y;
for(i=0;i<n;i++) for(j=0;j<m;j++)
{
x = i/(n-1.); y = j/(m-1.); i0 = i+n*j;
if(a) a->a[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y);
if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y);
}
}
or using C functions
void mgls_prepare2d(HMDT a, HMDT b=0, HMDT v=0)
{
register long i,j,n=50,m=40,i0;
if(a) mgl_data_create(a,n,m,1);
if(b) mgl_data_create(b,n,m,1);
if(v) { mgl_data_create(v,9,1,1); mgl_data_fill(v,-1,1,'x'); }
mreal x,y;
for(i=0;i<n;i++) for(j=0;j<m;j++)
{
x = i/(n-1.); y = j/(m-1.); i0 = i+n*j;
if(a) mgl_data_set_value(a, 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y), i,j,0);
if(b) mgl_data_set_value(b, 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y), i,j,0);
}
}
| • Surf sample: | ||
| • SurfC sample: | ||
| • SurfA sample: | ||
| • SurfCA sample: | ||
| • Mesh sample: | ||
| • Fall sample: | ||
| • Belt sample: | ||
| • Boxs sample: | ||
| • Tile sample: | ||
| • TileS sample: | ||
| • Dens sample: | ||
| • Cont sample: | ||
| • ContF sample: | ||
| • ContD sample: | ||
| • ContV sample: | ||
| • Axial sample: | ||
| • Grad sample: |
Next: 3D samples, Previous: 1D samples, Up: Examples [Contents][Index]