1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 1990 - INRIA - Serge Steer
3 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 // This file is hereby licensed under the terms of the GNU GPL v2.0,
6 // pursuant to article 5.3.4 of the CeCILL v.2.1.
7 // This file was originally licensed under the terms of the CeCILL v2.1,
8 // and continues to be available under such terms.
9 // For more information, see the COPYING file which you should have received
10 // along with this program.
12 function [x,y,z]=eval3dp(fun,p1,p2)
13 // eval3d - retourne une representation par facettes d'une fonction z=f(u,v)
15 // [x,y,z]=eval3dp(fun,p1,p2)
17 // fun : macro (de syntaxe : [x,y,z]=fun(p1,p2) ) definissant la
19 // Attention lors de l'appel de fun p1 et p2 sont des vecteurs
20 // et la macro doit retourner x,y,z tels que :
21 // [x(i),y(i),z(i)]=f(p1(i),p2(i))
23 // p1 : vecteur reel donnant la discretisation des valeurs du
25 // p2 : vecteur reel donnant la discretisation des valeurs du
27 // x : matrice 4xn dont chaque colonne contient les abscisses
29 // y : matrice 4xn dont chaque colonne contient les ordonnees
31 // z : matrice 4xn dont chaque colonne contient les cotes
34 // deff('[x,y,z]=scp(p1,p2)',['x=p1.*sin(p1).*cos(p2)';
35 // 'y=p1.*cos(p1).*cos(p2)';
37 // [x,y,z]=eval3dp(scp,0:0.3:2*%pi,-%pi:0.3:%pi);
38 // fac3d(x,y,z,35,45,'x@y@z')
40 // plot3d eval3d fac3d
45 error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "eval3dp", 3));
50 //on calcule la valeur de la fonction en tous le couples (p1(i),p2(j))
51 [vx,vy,vz]=fun(ones(1,n2).*.matrix(p1,1,n1),matrix(p2,1,n2).*.ones(1,n1))
54 //on genere les facettes
55 ind=ones(1,n1-1).*.[0 1 n1+1 n1]+ (1:n1-1).*.[1 1 1 1];
56 // ind=[1,2,n1+2,n1+1 , 2,3,n1+3,n1+2, .... ,n1-1,n1,2n1,2n1-1
58 ind2=ones(1,n2-1).*.ind+((0:n2-2)*n1).*.ones(ind);
61 x=matrix(vx(ind2),4,nx/4);
62 y=matrix(vy(ind2),4,nx/4);
63 z=matrix(vz(ind2),4,nx/4);