Split the plot3d examples + add images 42/10142/3
Sylvestre Ledru [Mon, 7 Jan 2013 17:26:22 +0000 (18:26 +0100)]
Change-Id: I633fe456d293650216200e09f3abd59b43f78a96

12 files changed:
scilab/modules/graphics/help/en_US/3d_plot/plot3d.xml
scilab/modules/helptools/images/plot3d_1.png
scilab/modules/helptools/images/plot3d_10.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_11.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_2.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_3.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_4.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_5.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_6.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_7.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_8.png [new file with mode: 0644]
scilab/modules/helptools/images/plot3d_9.png [new file with mode: 0644]

index e149570..ccb5bf0 100644 (file)
 t=[0:0.3:2*%pi]';
 z=sin(t)*cos(t');
 plot3d(t,t,z)
+ ]]></programlisting>
+        
+        <scilab:image>
+            t=[0:0.3:2*%pi]';
+            z=sin(t)*cos(t');
+            plot3d(t,t,z)
+        </scilab:image>
+        
+        <programlisting role="example"><![CDATA[
+t=[0:0.3:2*%pi]';
+z=sin(t)*cos(t');
 // same plot using facets computed by genfac3d
 [xx,yy,zz]=genfac3d(t,t,z);
-clf()
 plot3d(xx,yy,zz)
+ ]]></programlisting>
+        
+        <scilab:image>
+            t=[0:0.3:2*%pi]';
+            z=sin(t)*cos(t');
+            // same plot using facets computed by genfac3d
+            [xx,yy,zz]=genfac3d(t,t,z);
+            plot3d(xx,yy,zz)
+        </scilab:image>
+        
+        <programlisting role="example"><![CDATA[
 // multiple plots
-clf()
+t=[0:0.3:2*%pi]';
+z=sin(t)*cos(t');
+// same plot using facets computed by genfac3d
+[xx,yy,zz]=genfac3d(t,t,z);
 plot3d([xx xx],[yy yy],[zz 4+zz])
+ ]]></programlisting>
+        
+        <scilab:image>
+            // multiple plots
+            t=[0:0.3:2*%pi]';
+            z=sin(t)*cos(t');
+            // same plot using facets computed by genfac3d
+            [xx,yy,zz]=genfac3d(t,t,z);
+            plot3d([xx xx],[yy yy],[zz 4+zz])
+        </scilab:image>
+        
+        <programlisting role="example"><![CDATA[
 // multiple plots using colors
-clf()
+t=[0:0.3:2*%pi]';
+z=sin(t)*cos(t');
+// same plot using facets computed by genfac3d
+[xx,yy,zz]=genfac3d(t,t,z);
 plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))
+ ]]></programlisting>
+        
+        <scilab:image>
+            t=[0:0.3:2*%pi]';
+            z=sin(t)*cos(t');
+            // same plot using facets computed by genfac3d
+            [xx,yy,zz]=genfac3d(t,t,z);
+            plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))
+        </scilab:image>
+        
+        <programlisting role="example"><![CDATA[
 // simple plot with viewpoint and captions
-clf()
 plot3d(1:10,1:20,10*rand(10,20),alpha=35,theta=45,flag=[2,2,3])
+ ]]></programlisting>
+        
+        <scilab:image>
+            plot3d(1:10,1:20,10*rand(10,20),alpha=35,theta=45,flag=[2,2,3])
+        </scilab:image>
+        <programlisting role="example"><![CDATA[
 // plot of a sphere using facets computed by eval3dp
 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)";..
@@ -369,15 +424,44 @@ deff("[x,y,z]=sph(alp,tet)",["x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)";..
 r=1; orig=[0 0 0];
 [xx,yy,zz]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));
 clf();plot3d(xx,yy,zz)
-clf();
+ ]]></programlisting>
+        
+        <scilab:image>
+            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];
+            [xx,yy,zz]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));
+            clf();plot3d(xx,yy,zz)
+        </scilab:image>
+        
+        <programlisting role="example"><![CDATA[
 f=gcf();
 f.color_map = hotcolormap(128);
 r=0.3;orig=[1.5 0 0];
+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)"]);
+[xx,yy,zz]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));
 [xx1,yy1,zz1]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));
 cc=(xx+zz+2)*32;cc1=(xx1-orig(1)+zz1/r+2)*32;
 clf();plot3d1([xx xx1],[yy yy1],list([zz,zz1],[cc cc1]),theta=70,alpha=80,flag=[5,6,3])
-
-delete(gcf());
+ ]]></programlisting>
+        
+        <scilab:image>
+            f=gcf();
+            f.color_map = hotcolormap(128);
+            r=0.3;orig=[1.5 0 0];
+            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)"]);
+            [xx,yy,zz]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));
+            [xx1,yy1,zz1]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));
+            cc=(xx+zz+2)*32;cc1=(xx1-orig(1)+zz1/r+2)*32;
+            clf();plot3d1([xx xx1],[yy yy1],list([zz,zz1],[cc cc1]),theta=70,alpha=80,flag=[5,6,3])
+        </scilab:image>
+        
+        <programlisting role="example"><![CDATA[
 t=[0:0.3:2*%pi]'; z=sin(t)*cos(t');
 [xx,yy,zz]=genfac3d(t,t,z);
 plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))
@@ -414,7 +498,44 @@ TL.color = [c;c+1;c+2;c+3];
 h.data = TL;
 h.color_flag=3; // interpolated shading mode
  ]]></programlisting>
-        <scilab:image>plot3d();</scilab:image>
+        
+        <scilab:image>
+            t=[0:0.3:2*%pi]'; z=sin(t)*cos(t');
+            [xx,yy,zz]=genfac3d(t,t,z);
+            plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))
+            e=gce();
+            f=e.data;
+            TL = tlist(["3d" "x" "y" "z" "color"],f.x,f.y,f.z,6*rand(f.z)); // random color matrix
+            e.data = TL;
+            TL2 = tlist(["3d" "x" "y" "z" "color"],f.x,f.y,f.z,4*rand(1,800)); // random color vector
+            e.data = TL2;
+            TL3 = tlist(["3d" "x" "y" "z" "color"],f.x,f.y,f.z,[20*ones(1,400) 6*ones(1,400)]);
+            e.data = TL3;
+            TL4 = tlist(["3d" "x" "y" "z"],f.x,f.y,f.z); // no color
+            e.data = TL4;
+            e.color_flag=1 // color index proportional to altitude (z coord.)
+            e.color_flag=2; // back to default mode
+            e.color_flag= 3; // interpolated shading mode (based on blue default color)
+            clf()
+            plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))
+            h=gce(); //get handle on current entity (here the surface)
+            a=gca(); //get current axes
+            a.rotation_angles=[40,70];
+            a.grid=[1 1 1]; //make grids
+            a.data_bounds=[-6,0,-1;6,6,5];
+            a.axes_visible="off"; //axes are hidden
+            a.axes_bounds=[.2 0 1 1];
+            h.color_flag=1; //color according to z
+            h.color_mode=-2;  //remove the facets boundary by setting color_mode to white color
+            h.color_flag=2; //color according to given colors
+            h.color_mode = -1; // put the facets boundary back by setting color_mode to black color
+            f=gcf();//get the handle of the parent figure
+            f.color_map=hotcolormap(512);
+            c=[1:400,1:400];
+            TL.color = [c;c+1;c+2;c+3];
+            h.data = TL;
+            h.color_flag=3; // interpolated shading mode
+        </scilab:image>
         <para>We can use the plot3d function to plot a set of patches (triangular,
             quadrangular, etc).
         </para>
@@ -448,7 +569,6 @@ tcolor = [2 3]';
 subplot(2,2,1);
 plot3d(x,y,list(z,tcolor));
 xtitle('A triangle set of patches');
-
 // Example 2: a mixture of triangular and quadrangular patches
 
 xquad = [5, 0;
@@ -533,6 +653,111 @@ h = gcf();
 h.children(1).background = 1;
 xtitle('A standard rabbit set of patches');
  ]]></programlisting>
+        
+        <scilab:image>
+            
+            x = [0 0;
+            0 1;
+            1 1];
+            
+            y = [1 1;
+            2 2;
+            2 1];
+            
+            z = [1 1;
+            1 1;
+            1 1];
+            
+            tcolor = [2 3]';
+            
+            subplot(2,2,1);
+            plot3d(x,y,list(z,tcolor));
+            xtitle('A triangle set of patches');
+            // Example 2: a mixture of triangular and quadrangular patches
+            
+            xquad = [5, 0;
+            10,0;
+            15,5;
+            10,5];
+            
+            yquad = [15,0;
+            20,10;
+            15,15;
+            10,5];
+            
+            zquad = ones(4,2);
+            
+            xtri = [ 0,10,10, 5, 0;
+            10,20,20, 5, 0;
+            20,20,15,10,10];
+            
+            ytri = [ 0,10,20, 5,10;
+            10,20,20,15,20;
+            0, 0,15,10,20];
+            
+            ztri = zeros(3,5);
+            
+            subplot(2,2,3);
+            plot3d(xquad,yquad,zquad);
+            plot3d(xtri,ytri,ztri);
+            xtitle('Mixing triangle and quadrangle set of patches');
+            
+            // Example 3: some rabbits
+            
+            rabxtri = [ 5,  5, 2.5,  7.5, 10;
+            5, 15, 5,   10,   10;
+            15, 15, 5,   10,   15];
+            
+            rabytri = [10, 10, 9.5,  2.5, 0;
+            20, 10, 12,   5,   5;
+            10   0   7    0    0];
+            rabztri = [0,0,0,0,0;
+            0,0,0,0,0;
+            0,0,0,0,0];
+            
+            rabtricolor_byface = [2 2 2 2 2];
+            
+            rabtricolor = [2,2,2,2,2;
+            3,3,3,3,3;
+            4,4,4,4,4];
+            
+            rabxquad = [0, 1;
+            0, 6;
+            5,11;
+            5, 6];
+            
+            rabyquad = [18,23;
+            23,28;
+            23,28;
+            18,23];
+            
+            rabzquad = [1,1;
+            1,1;
+            1,1;
+            1,1];
+            
+            rabquadcolor_byface = [2 2];
+            
+            rabquadcolor = [2,2;
+            3,3;
+            4,4;
+            5,5];
+            
+            subplot(2,2,2);
+            plot3d(rabxtri, rabytri, list(rabztri,rabtricolor));
+            plot3d(rabxquad,rabyquad,list(rabzquad,rabquadcolor));
+            h = gcf();
+            h.children(1).background = 1;
+            xtitle('A psychedelic rabbit set of patches');
+            
+            subplot(2,2,4);
+            plot3d(rabxtri, rabytri, list(rabztri,rabtricolor_byface));
+            plot3d(rabxquad,rabyquad,list(rabzquad,rabquadcolor_byface));
+            h = gcf();
+            h.children(1).background = 1;
+            xtitle('A standard rabbit set of patches');
+        </scilab:image>
+        
         <para>We can also use the plot3d function to plot a set of patches using
             vertex and faces.
         </para>
@@ -586,6 +811,7 @@ face = [1 2 3;
 xvf = matrix(vertex(face,1),size(face,1),length(vertex(face,1))/size(face,1))';
 yvf = matrix(vertex(face,2),size(face,1),length(vertex(face,1))/size(face,1))';
 zvf = matrix(zeros(vertex(face,2)),size(face,1),length(vertex(face,1))/size(face,1))';
+tcolor = [2 3]';
 
 subplot(2,1,2);
 plot3d(xvf,yvf,list(zvf,tcolor));
@@ -593,6 +819,60 @@ xtitle('A triangle set of patches - vertex / face mode - 2D');
 a = gca();
 a.view = '2d';
  ]]></programlisting>
+        <scilab:image>
+            
+            vertex = [0 1 1;
+            0 2 2;
+            1 2 3;
+            1 1 4];
+            
+            // The face list indicates which points are composing the patch.
+            face = [1 2 3;
+            1 3 4];
+            
+            tcolor = [2 3]';
+            
+            // The formula used to translate the vertex / face representation into x, y, z lists
+            
+            xvf = matrix(vertex(face,1),size(face,1),length(vertex(face,1))/size(face,1))';
+            yvf = matrix(vertex(face,2),size(face,1),length(vertex(face,1))/size(face,1))';
+            zvf = matrix(vertex(face,3),size(face,1),length(vertex(face,1))/size(face,1))';
+            
+            scf();
+            subplot(2,1,1);
+            plot3d(xvf,yvf,list(zvf,tcolor));
+            xtitle('A triangle set of patches - vertex / face mode - 3d');
+            
+            // 2D test
+            // We use the 3D representation with a 0 Z values and then switch to 2D representation
+            
+            // Vertex / Faces example: 3D example
+            
+            // The vertex list contains the list of unique points composing each patch
+            // The points common to 2 patches are not repeated in the vertex list
+            
+            vertex = [0 1;
+            0 2;
+            1 2;
+            1 1];
+            
+            // The face list indicates which points are composing the patch.
+            face = [1 2 3;
+            1 3 4];
+            
+            // The formula used to translate the vertex / face representation into x, y, z lists
+            
+            xvf = matrix(vertex(face,1),size(face,1),length(vertex(face,1))/size(face,1))';
+            yvf = matrix(vertex(face,2),size(face,1),length(vertex(face,1))/size(face,1))';
+            zvf = matrix(zeros(vertex(face,2)),size(face,1),length(vertex(face,1))/size(face,1))';
+            tcolor = [2 3]';
+            
+            subplot(2,1,2);
+            plot3d(xvf,yvf,list(zvf,tcolor));
+            xtitle('A triangle set of patches - vertex / face mode - 2D');
+            a = gca();
+            a.view = '2d';
+        </scilab:image>
         <para> How to set manually some ticks </para>
         <programlisting role="example"><![CDATA[
 plot3d();
@@ -601,6 +881,14 @@ h.x_ticks = tlist(['ticks','locations','labels'],[-2,-1,0,1,2],['-2','-1','0','1
 h.y_ticks = tlist(['ticks','locations','labels'],[-4,-3,-2,-1,0,1,2,3,4],['-4','-3','-2','-1','0','1','2','3','4']);
 h.z_ticks = tlist(['ticks','locations','labels'],[-1,0,1],['Point 1','Point 2','Point 3']);
  ]]></programlisting>
+        <scilab:image>
+            plot3d();
+            h = gca();
+            h.x_ticks = tlist(['ticks','locations','labels'],[-2,-1,0,1,2],['-2','-1','0','1','2']);
+            h.y_ticks = tlist(['ticks','locations','labels'],[-4,-3,-2,-1,0,1,2,3,4],['-4','-3','-2','-1','0','1','2','3','4']);
+            h.z_ticks = tlist(['ticks','locations','labels'],[-1,0,1],['Point 1','Point 2','Point 3']);
+        </scilab:image>
+        
         <para/>
     </refsection>
     <refsection role="see also">
index 54fbb0f..c2736c8 100644 (file)
Binary files a/scilab/modules/helptools/images/plot3d_1.png and b/scilab/modules/helptools/images/plot3d_1.png differ
diff --git a/scilab/modules/helptools/images/plot3d_10.png b/scilab/modules/helptools/images/plot3d_10.png
new file mode 100644 (file)
index 0000000..9a32e38
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_10.png differ
diff --git a/scilab/modules/helptools/images/plot3d_11.png b/scilab/modules/helptools/images/plot3d_11.png
new file mode 100644 (file)
index 0000000..d7832b6
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_11.png differ
diff --git a/scilab/modules/helptools/images/plot3d_2.png b/scilab/modules/helptools/images/plot3d_2.png
new file mode 100644 (file)
index 0000000..da71cf0
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_2.png differ
diff --git a/scilab/modules/helptools/images/plot3d_3.png b/scilab/modules/helptools/images/plot3d_3.png
new file mode 100644 (file)
index 0000000..f46f674
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_3.png differ
diff --git a/scilab/modules/helptools/images/plot3d_4.png b/scilab/modules/helptools/images/plot3d_4.png
new file mode 100644 (file)
index 0000000..012e85f
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_4.png differ
diff --git a/scilab/modules/helptools/images/plot3d_5.png b/scilab/modules/helptools/images/plot3d_5.png
new file mode 100644 (file)
index 0000000..9008841
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_5.png differ
diff --git a/scilab/modules/helptools/images/plot3d_6.png b/scilab/modules/helptools/images/plot3d_6.png
new file mode 100644 (file)
index 0000000..336cd39
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_6.png differ
diff --git a/scilab/modules/helptools/images/plot3d_7.png b/scilab/modules/helptools/images/plot3d_7.png
new file mode 100644 (file)
index 0000000..c37b5b1
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_7.png differ
diff --git a/scilab/modules/helptools/images/plot3d_8.png b/scilab/modules/helptools/images/plot3d_8.png
new file mode 100644 (file)
index 0000000..f514c9d
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_8.png differ
diff --git a/scilab/modules/helptools/images/plot3d_9.png b/scilab/modules/helptools/images/plot3d_9.png
new file mode 100644 (file)
index 0000000..a46c80c
Binary files /dev/null and b/scilab/modules/helptools/images/plot3d_9.png differ