File: genfac3d.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (43 lines) | stat: -rw-r--r-- 1,378 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function [xx,yy,zz]=genfac3d(x,y,zmat,mask)
// genfac - transforms  standard 3d data to four sides facets representation
//%Syntax
// [xx,yy,zz]=genfac3d(x,y,zmat,mask)
//%Parameters
// zmat      : matrix , zmat(i,j)= F(x(j),y(i))
// x        : x axis coordinates vector
// y        : y axis coordinates vector
// mask     : boolean optional matrix with same size as zmat used to select 
//            entries of zmat to be represented by facets
// xx,yy,zz :4xn  matrices. xx(:,i),yy(:,i),zz(:,i) are respectively the 
//           x-axis,y-axis and z-axis coordinates of the ith facet
//%Examples
//  genfac3d() 
//!
// Copyright INRIA
[lhs,rhs]=argn(0)
if rhs <=0 then
  s_mat=['t=(0:10)''*%pi/5;';
         '  zmat=sin(t)*cos(t'');';
	 '[xx,yy,zz]=genfac3d(t,t,zmat,zmat>=0);';
	 'plot3d(xx,yy,zz)'];
  write(%io(2),s_mat);execstr(s_mat);
  return;
end;
[nr,nc]=size(zmat)
indy=(ones(1,nc-1).*.[0;1;1;0]+(1:nc-1).*.[1;1;1;1]).*.ones(1,nr-1);
indx=ones(1,nc-1).*.(ones(1,nr-1).*.[0;0;1;1]+(1:nr-1).*.[1;1;1;1]);
[nrl,nrc]=size(indx)
indx=matrix(indx,nrl*nrc,1);
indy=matrix(indy,nrl*nrc,1);
indz=indx+(nr)*(indy-1*ones(indy));
[nrl,nrc]=size(indx);
xx=matrix(x(indx),4,nrl*nrc/4);
yy=matrix(y(indy),4,nrl*nrc/4);
zz=matrix(zmat(indz),4,nrl*nrc/4);
if rhs==4 then 
  zl=matrix(mask(indz),4,nrl*nrc/4);
  [xin,yin]=find(zl);
  zz=zz(:,yin);
  xx=xx(:,yin);
  yy=yy(:,yin);
end