File: generate3dSegments.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 (35 lines) | stat: -rw-r--r-- 853 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
function [X,Y,Z]=generate3dSegments(X,Y,Z,isParametric)

//
// Generates segmets 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, 2009
//

[nv,nu]=size(Z);

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

ind=ones(1,nv-1).*.[0 1 1 nv+1 nv+1 nv nv 0]+ (1:nv-1).*.[1 1 1 1 1 1 1 1];

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