summaryrefslogtreecommitdiff
path: root/modules/graphics/demos/surface
diff options
context:
space:
mode:
Diffstat (limited to 'modules/graphics/demos/surface')
-rwxr-xr-xmodules/graphics/demos/surface/Macros.sci79
-rwxr-xr-xmodules/graphics/demos/surface/bh.sce42
-rwxr-xr-xmodules/graphics/demos/surface/cplxroot.sce20
-rwxr-xr-xmodules/graphics/demos/surface/hole3d.sce28
-rwxr-xr-xmodules/graphics/demos/surface/hole3d1.sce41
-rwxr-xr-xmodules/graphics/demos/surface/moebius.sce41
-rwxr-xr-xmodules/graphics/demos/surface/rings.sce35
-rwxr-xr-xmodules/graphics/demos/surface/shell.sce38
-rwxr-xr-xmodules/graphics/demos/surface/sphere.sce40
-rwxr-xr-xmodules/graphics/demos/surface/spiral.sce38
-rwxr-xr-xmodules/graphics/demos/surface/surfaces.dem.gateway.sce22
-rwxr-xr-xmodules/graphics/demos/surface/torus.sce42
-rwxr-xr-xmodules/graphics/demos/surface/torus1.sce38
-rwxr-xr-xmodules/graphics/demos/surface/tube.sce42
14 files changed, 546 insertions, 0 deletions
diff --git a/modules/graphics/demos/surface/Macros.sci b/modules/graphics/demos/surface/Macros.sci
new file mode 100755
index 000000000..0878d15ed
--- /dev/null
+++ b/modules/graphics/demos/surface/Macros.sci
@@ -0,0 +1,79 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+funcprot(0);
+
+function [X,Y]=field(x,y)
+ // x and y are two vectors defining a grid
+ // X and Y are two matrices which gives the grid point coordinates
+ //-------------------------------------------------------------
+ [rx,cx]=size(x);
+ [ry,cy]=size(y);
+ if rx<>1, write(%io(2),"x must be a row vector");return;end;
+ if ry<>1, write(%io(2),"y must be a row vector");return;end;
+ X=x.*.ones(cy,1);
+ Y=y'.*.ones(1,cx);
+endfunction
+
+function [z]=dup(x,n)
+ // utility
+ // x is a vector this function returns [x,x,x,x...] or [x;x;x;x;..]
+ // depending on x
+ [nr,nc]=size(x)
+ if nr==1 then
+ y=ones(n,1);
+ z= x.*.y ;
+ else
+ if nc<>1 then
+ error("dup : x must be a vector");
+ else
+ y=ones(1,n);
+ z= x.*.y ;
+ end
+ end
+endfunction
+
+function cplxmap(z,w,varargin)
+ //cplxmap(z,w,T,A,leg,flags,ebox)
+ //cplxmap Plot a function of a complex variable.
+ // cplxmap(z,f(z))
+ x = real(z);
+ y = imag(z);
+ u = real(w);
+ v = imag(w);
+ M = max(u);
+ m = min(u);
+ s = ones(size(z));
+ //mesh(x,y,m*s,blue*s);
+ //hold on
+ [X,Y,U]=nf3d(x,y,u);
+ [X,Y,V]=nf3d(x,y,v);
+ Colors = sum(V,"r");
+ Colors = Colors - min(Colors);
+ Colors = 32*Colors/max(Colors);
+ plot3d1(X,Y,list(U,Colors),varargin(:))
+endfunction
+
+function cplxroot(n,m,varargin)
+ //cplxroot(n,m,T,A,leg,flags,ebox)
+ //CPLXROOT Riemann surface for the n-th root.
+ // CPLXROOT(n) renders the Riemann surface for the n-th root.
+ // CPLXROOT, by itself, renders the Riemann surface for the cube root.
+ // CPLXROOT(n,m) uses an m-by-m grid. Default m = 20.
+ // Use polar coordinates, (r,theta).
+ // Cover the unit disc n times.
+ [lhs,rhs]=argn(0)
+ if rhs < 1, n = 3; end
+ if rhs < 2, m = 20; end
+ r = (0:m)'/m;
+ theta = - %pi*(-n*m:n*m)/m;
+ z = r * exp(%i*theta);
+ s = r.^(1/n) * exp(%i*theta/n);
+ cplxmap(z,s,varargin(:))
+endfunction
+
+funcprot(1);
diff --git a/modules/graphics/demos/surface/bh.sce b/modules/graphics/demos/surface/bh.sce
new file mode 100755
index 000000000..1fc957328
--- /dev/null
+++ b/modules/graphics/demos/surface/bh.sce
@@ -0,0 +1,42 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// bh()
+// =============================================================================
+
+
+function bh(nn)
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+
+ // a black hole
+
+ x = linspace(0,2*%pi,nn);
+ t = linspace(0,1,20);
+ cosphi = dup(cos(x),length(t));
+ sinphi = dup(sin(x),length(t));
+ f = dup((t.*t+0.2)',length(x));
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+ demo_viewCode("bh.sce");
+
+
+ my_handle.immediate_drawing = "off";
+ plot3d2(f.*cosphi,f.*sinphi,dup(t'.*2-1,length(x)));
+ my_plot = my_axe.children;
+ my_handle.color_map = jetcolormap(128);
+ my_plot.color_flag = 1;
+ my_axe.rotation_angles = [70,20];
+ my_handle.immediate_drawing = "on";
+
+endfunction
+
+bh(50);
+clear bh;
diff --git a/modules/graphics/demos/surface/cplxroot.sce b/modules/graphics/demos/surface/cplxroot.sce
new file mode 100755
index 000000000..84ad4ed41
--- /dev/null
+++ b/modules/graphics/demos/surface/cplxroot.sce
@@ -0,0 +1,20 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+function demo_cplxroot()
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ cplxroot(2,20,130,45);
+ demo_viewCode("cplxroot.sce");
+
+endfunction
+
+demo_cplxroot();
+clear demo_cplxroot; \ No newline at end of file
diff --git a/modules/graphics/demos/surface/hole3d.sce b/modules/graphics/demos/surface/hole3d.sce
new file mode 100755
index 000000000..b8ee74564
--- /dev/null
+++ b/modules/graphics/demos/surface/hole3d.sce
@@ -0,0 +1,28 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// hole3d : Holes in surfaces using %inf
+// =============================================================================
+
+function hole3d()
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ demo_viewCode("hole3d.sce");
+
+ t = linspace(-%pi,%pi,40);
+ z = sin(t)'*cos(t);
+ z1 = find(abs(z) > 0.5);
+ z(z1) = %inf*z1;
+ plot3d1(t,t,z);
+
+endfunction
+
+hole3d();
+clear hole3d;
diff --git a/modules/graphics/demos/surface/hole3d1.sce b/modules/graphics/demos/surface/hole3d1.sce
new file mode 100755
index 000000000..5961888b4
--- /dev/null
+++ b/modules/graphics/demos/surface/hole3d1.sce
@@ -0,0 +1,41 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// hole3d1 : Holes in surfaces using %inf
+// =============================================================================
+
+function hole3d1()
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+
+ deff("[x,y,z]=sph(alp,tet)",["x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)";
+ "y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)";
+ "z=r*sin(alp)+orig(3)*ones(tet)"]);
+
+ r=1;
+ orig=[0 0 0];
+ x=linspace(-%pi/2,%pi/2,40);y=linspace(0,%pi*2,20);
+ x(5:8)=%inf*ones(5:8);
+ x(30:35)=%inf*ones(30:35);
+ [x1,y1,z1]=eval3dp(sph,x,y);
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+
+ demo_viewCode("hole3d1.sce");
+
+ my_handle.immediate_drawing = "off";
+ plot3d1(x1,y1,z1);
+ my_axe.rotation_angles = [70,20];
+ my_handle.immediate_drawing = "on";
+
+endfunction
+
+hole3d1();
+clear hole3d1;
diff --git a/modules/graphics/demos/surface/moebius.sce b/modules/graphics/demos/surface/moebius.sce
new file mode 100755
index 000000000..9f74d1e97
--- /dev/null
+++ b/modules/graphics/demos/surface/moebius.sce
@@ -0,0 +1,41 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// moebius()
+// =============================================================================
+
+function moebius()
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+ // the Moebius band
+ t=linspace(-1,1,20)';
+ x=linspace(0,%pi,40);
+ my_factor=2+ t*cos(x);
+ X=my_factor*diag(cos(2*x));
+ Y=my_factor*diag(sin(2*x));
+ Z=t*sin(x);
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+
+ demo_viewCode("moebius.sce");
+
+ my_handle.immediate_drawing = "off";
+ plot3d2(X,Y,Z);
+ my_plot = my_axe.children;
+ my_handle.color_map = jetcolormap(128);
+ my_plot.color_flag = 1;
+ my_axe.rotation_angles = [88,56];
+ my_handle.immediate_drawing = "on";
+
+
+endfunction
+
+moebius();
+clear moebius;
diff --git a/modules/graphics/demos/surface/rings.sce b/modules/graphics/demos/surface/rings.sce
new file mode 100755
index 000000000..b5d743209
--- /dev/null
+++ b/modules/graphics/demos/surface/rings.sce
@@ -0,0 +1,35 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// rings()
+// =============================================================================
+
+function rings()
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+ my_handle = scf(100001);
+
+ rr = 0.2;
+ t = linspace(0,2*%pi,10);
+ s = linspace(0,2*%pi,41); n=length(s);
+ r = dup(1+cos(t)*rr,n)'; m=length(t);
+ x = dup(cos(s),m).*r; y=dup(sin(s),m).*r;
+ z = dup(sin(t)*rr,n)';
+ X = [x;(x+1.3);(x-1.3)];
+ Y = [y;-z;-z];
+ Z = [z;y;y];
+
+ clf(my_handle,"reset");
+ demo_viewCode("rings.sce");
+
+ plot3d2(X,Y,Z,[m,2*m]);
+
+endfunction
+
+rings();
+clear rings;
diff --git a/modules/graphics/demos/surface/shell.sce b/modules/graphics/demos/surface/shell.sce
new file mode 100755
index 000000000..6d4380dea
--- /dev/null
+++ b/modules/graphics/demos/surface/shell.sce
@@ -0,0 +1,38 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// shell()
+// =============================================================================
+
+function shell()
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+ u = linspace(0,2*%pi,40);
+ v = linspace(0,2*%pi,20);
+ x= (cos(u).*u)'*(1+cos(v)/2);
+ y= (u/2)'*sin(v);
+ z= (sin(u).*u)'*(1+cos(v)/2);
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+
+ demo_viewCode("shell.sce");
+
+ my_handle.immediate_drawing = "off";
+ plot3d2(x,y,z);
+ my_plot = my_axe.children;
+ my_handle.color_map = jetcolormap(128);
+ my_plot.color_flag = 1;
+ my_axe.rotation_angles = [51,96];
+ my_handle.immediate_drawing = "on";
+
+endfunction
+
+shell();
+clear shell;
diff --git a/modules/graphics/demos/surface/sphere.sce b/modules/graphics/demos/surface/sphere.sce
new file mode 100755
index 000000000..f604be7c3
--- /dev/null
+++ b/modules/graphics/demos/surface/sphere.sce
@@ -0,0 +1,40 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// sphere()
+// =============================================================================
+
+function sphere()
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+
+ u = linspace(-%pi/2,%pi/2,40);
+ v = linspace(0,2*%pi,20);
+ x = cos(u)'*cos(v);
+ y = cos(u)'*sin(v);
+ z = sin(u)'*ones(v);
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+
+ demo_viewCode("sphere.sce");
+
+ my_handle.immediate_drawing = "off";
+ plot3d2(x,y,z);
+ my_plot = my_axe.children;
+ my_handle.color_map = jetcolormap(128);
+ my_plot.color_flag = 1;
+ my_axe.rotation_angles = [51,96];
+ my_axe.isoview = "on";
+ my_handle.immediate_drawing = "on";
+
+endfunction
+
+sphere();
+clear sphere;
diff --git a/modules/graphics/demos/surface/spiral.sce b/modules/graphics/demos/surface/spiral.sce
new file mode 100755
index 000000000..d23145f93
--- /dev/null
+++ b/modules/graphics/demos/surface/spiral.sce
@@ -0,0 +1,38 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// spiral()
+// =============================================================================
+
+function hole3d1()
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+ [r,a]=field(0:0.1:1,0:%pi/8:6*%pi);
+ z=a/8;
+ x=r.*cos(a).*(1-a/20);
+ y=r.*sin(a).*(1-a/20);
+ z=z-1.5;
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+
+ demo_viewCode("spiral.sce");
+
+ my_handle.immediate_drawing = "off";
+ plot3d2(x,y,z);
+ my_plot = my_axe.children;
+ my_handle.color_map = jetcolormap(128);
+ my_plot.color_flag = 1;
+ my_axe.rotation_angles = [51,96];
+ my_handle.immediate_drawing = "on";
+
+endfunction
+
+hole3d1();
+clear hole3d1;
diff --git a/modules/graphics/demos/surface/surfaces.dem.gateway.sce b/modules/graphics/demos/surface/surfaces.dem.gateway.sce
new file mode 100755
index 000000000..7cec88227
--- /dev/null
+++ b/modules/graphics/demos/surface/surfaces.dem.gateway.sce
@@ -0,0 +1,22 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+demopath = get_absolute_file_path("surfaces.dem.gateway.sce");
+
+subdemolist=["Surface with holes 1" , "hole3d.sce" ; ..
+"Surface with holes 2" , "hole3d1.sce" ; ..
+"Sphere" , "sphere.sce" ; ..
+"Shell" , "shell.sce" ; ..
+"Spiral" , "spiral.sce" ; ..
+"Rings" , "rings.sce" ; ..
+"Torus" , "torus.sce" ; ..
+"Torus 1" , "torus1.sce" ; ..
+"Moebius" , "moebius.sce" ; ..
+"Tube" , "tube.sce" ; ..
+"Black Hole" , "bh.sce" ; ..
+"Riemann surface (n=2)" , "cplxroot.sce" ];
+
+subdemolist(:,2) = demopath + subdemolist(:,2);
+clear demopath; \ No newline at end of file
diff --git a/modules/graphics/demos/surface/torus.sce b/modules/graphics/demos/surface/torus.sce
new file mode 100755
index 000000000..82bac597a
--- /dev/null
+++ b/modules/graphics/demos/surface/torus.sce
@@ -0,0 +1,42 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// torus : a torus with a thick and a thin side.
+// =============================================================================
+
+function torus
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+
+ // some torus type bodies.
+ x=linspace(0,2*%pi,40);
+ y=linspace(0,2*%pi,20)';
+ // a torus with a thick and a thin side.
+ my_factor=1.5+cos(y)*(cos(x)/2+0.6);
+ X=my_factor*diag(cos(x));
+ Y=my_factor*diag(sin(x));
+ Z=sin(y)*(cos(x)/2+0.6);
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+
+ demo_viewCode("torus.sce");
+
+ my_handle.immediate_drawing = "off";
+ plot3d2(X,Y,Z);
+ my_plot = my_axe.children;
+ my_handle.color_map = jetcolormap(128);
+ my_plot.color_flag = 1;
+ my_axe.rotation_angles = [68,95];
+ my_handle.immediate_drawing = "on";
+
+endfunction
+
+torus();
+clear torus;
diff --git a/modules/graphics/demos/surface/torus1.sce b/modules/graphics/demos/surface/torus1.sce
new file mode 100755
index 000000000..e75997c5b
--- /dev/null
+++ b/modules/graphics/demos/surface/torus1.sce
@@ -0,0 +1,38 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// torus1 : a deformed torus
+// =============================================================================
+
+function torus1
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+ x=linspace(0,2*%pi,40);
+ y=linspace(0,2*%pi,20)';
+ my_factor=1.5+cos(y);
+ X=my_factor*cos(x);
+ Y=my_factor*sin(x);
+ Z=sin(y)*ones(x)+ ones(y)*cos(2*x);
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+ demo_viewCode("torus1.sce");
+
+ my_handle.immediate_drawing = "off";
+ plot3d2(X,Y,Z);
+ my_plot = my_axe.children;
+ my_handle.color_map = jetcolormap(128);
+ my_plot.color_flag = 1;
+ my_axe.rotation_angles = [30,110];
+ my_handle.immediate_drawing = "on";
+
+endfunction
+
+torus1();
+clear torus1;
diff --git a/modules/graphics/demos/surface/tube.sce b/modules/graphics/demos/surface/tube.sce
new file mode 100755
index 000000000..f6cc22085
--- /dev/null
+++ b/modules/graphics/demos/surface/tube.sce
@@ -0,0 +1,42 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+//
+
+// =============================================================================
+// tube : some tube like bodies.
+// =============================================================================
+
+function tube(nn)
+
+ exec("SCI/modules/graphics/demos/surface/Macros.sci",-1);
+
+ x=linspace(0,2*%pi,nn);
+ // atomic modell or so.
+ y=0.1+[sin(linspace(0,%pi,15)),1.5*sin(linspace(0,%pi,10)),sin(linspace(0,%pi,15))];
+ cosphi=dup(cos(x),length(y));
+ sinphi=dup(sin(x),length(y));
+ f=dup(y',length(x));
+ x1=f.*cosphi; y1=f.*sinphi;
+ z=dup(linspace(-2,2,prod(size(y)))',prod(size(x)));
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ my_axe = my_handle.children;
+
+ demo_viewCode("tube.sce");
+
+ my_handle.immediate_drawing = "off";
+ plot3d2(x1,y1,z,-1,35,70);
+ my_plot = my_axe.children;
+ my_handle.color_map = jetcolormap(128);
+ my_plot.color_flag = 1;
+ my_axe.rotation_angles = [70,48];
+ my_handle.immediate_drawing = "on";
+
+endfunction
+
+tube(50);
+clear tube;