[scilab-Users] Drawing a pierced rectangle facet

Samuel Gougeon Samuel.Gougeon at univ-lemans.fr
Fri Oct 29 01:27:49 CEST 2010


Hello Jens,

Jens Simon <j.s.strom at hslmg.de> a écrit :

> Hallo Scilab experts,
> I have come to the below script. Does anayone know a simpler, more elegant
> solution? Please advise.

Here after is another solution, for this funny figure.
Because your sample is flat and at constant Z,
it is possible to draw it with xfpoly().
I remender that there was a demo with mesh2d() from
the Metanet module, meshing a similar shape.
Metanet has been removed from Scilab, and this demo
has been removed from the module. It is somewhat a pity..
Here, no mesh no calculation, just for display.
Try it and enjoy.

Regards
Samuel

PS: I tried with plot3d() according to the same philosophy,
but it does not work. I didn't figure out why...
PS: The script looks longer than yours because statements
are on separated lines, + comments + 1 holy bonus ;)
-----
// Flat rectangle into (xOy)
rdX = 5;
rdY = 3;
rXY = [ 0 0 rdX rdX 0 ; 0 rdY rdY 0 0 ]';

// Flat circular hole into (x0y)
n  = 40;   // number of edges
theta = linspace(-%pi,%pi,n+1)';
R = 1;     // radius
cXo = 3.75; // center's position
cYo = 1.2;
cXY = [ [ cXo+R*cos(theta) ; 0 ] [cYo+R*sin(theta) ; 0 ] ];
// Another one
R2 = 0.3; cXo2 = 1; cYo2 = 2;
cXY2= [ [ cXo2+R2*cos(theta); 0] [cYo2+R2*sin(theta); 0] ];

// Connecting & Plotting the whole
XY = cat(1,[ 0 0 ], cXY, cXY2, rXY);
clf
param3d([0 rdX rdX],[0 0 rdY],[0 0 0]) // setting axes bounds...
xfpoly(XY(:,1),XY(:,2));  // ... because xfpoly() does not do it!
e = gce();
//e.line_mode = "off";
e.background = color("blue");
ca = gca(); ca.isoview="on";

================================


> Kind regards, Jens
> -------------------------------------------------------------------------
>
> a=5; b=3; r=1; n=10; ex0=3.75; ey0=1.2; //data of rectangle and regular n-gon
> phi=linspace(-3*%pi/4,5*%pi/4,4*n+1);
> ex=r*cos(phi)+ex0; ey=r*sin(phi)+ey0;  
> ez=zeros(1,4*n+1);//coordinates of regular
> n-gon
> zer=zeros(1,n); one=ones(1,n);
> ax=0:a/n:a-a/n; ay=zer; az=zer;     //coordinates of rectangle edge a
> bx=a*one; by=0:b/n:b-b/n; bz=zer;   //coordinates of rectangle edge b
> cx=a:-a/n:a/n; cy=b*one; cz=zer;    //coordinates of rectangle edge c
> dx=[zer 0]; dy=b:-b/n:0; dz=[zer 0];//coordinates of rectangle edge d
> x=[ax bx cx dx; ex];
> y=[ay by cy dy; ey];
> z=[az bz cz dz; ez];
> xdel(), plot3d2(x,y,z)
> ca=gca();
> ca.isoview="on";





More information about the users mailing list