File: generate3dPolygons.sci

package info (click to toggle)
scilab-plotlib 0.41-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,196 kB
  • sloc: xml: 3,308; makefile: 15
file content (53 lines) | stat: -rw-r--r-- 1,262 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
44
45
46
47
48
49
50
51
52
53
function [X,Y,Z]=generate3dPolygons(T,X,Y,Z,nbVertices,isParametric)

//
// Generates polygons (N=3 trianges or N=4 quadrilaters) from
// numerical parametric data X,Y,Z (matrices of the same size)
//
// This function is a quick hack from SCI/macros/xdess/eval3dp.sci
// Original code due to S. Steer, (C) INRIA
//
// S. Mottelet, UTC, 99
//

if T==[]

  [nv,nu]=size(Z);

  rev=$:-1:1;
  
  X=X(:)';Y=Y(:);Z=Z(:);
   
  if isParametric 
  //   X=X(rev,:);Y=Y(rev,:);Z=Z(rev,:); // to solve the pb with plot3d1
  else
    X=X(rev);
    Z=Z(:,rev);
//     X=ones(1,nu).*.matrix(X,1,nv);
//     Y=matrix(Y,1,nu).*.ones(1,nv);
    X=X(ones(1,nv),rev);
    Y=Y(:,ones(1,nu));
  end

  if nbVertices==4
     ind=ones(1,nv-1).*.[0 1 nv+1 nv]+ (1:nv-1).*.[1 1 1 1];
  elseif nbVertices==3
     ind=ones(1,nv-1).*.[0 1 nv 1 nv+1 nv]+ (1:nv-1).*.[1 1 1 1 1 1];
  else
     _error('generate3dPolygons : nb of vertices must be 3 or 4');
  end

  ind2=ones(1,nu-1).*.ind+((0:nu-2)*nv).*.ones(ind);
  n=prod(size(ind2));
  X=matrix(X(ind2),nbVertices,n/nbVertices);
  Y=matrix(Y(ind2),nbVertices,n/nbVertices);
  Z=matrix(Z(ind2),nbVertices,n/nbVertices);	 

else
  ntri=size(T,2);
  Z=matrix(Z(T),3,ntri);
  X=matrix(X(T),3,ntri); 
  Y=matrix(Y(T),3,ntri);
end

endfunction