1 view (last 30 days)
Pietro Elia on 18 Oct 2020
Answered: Pietro Elia on 26 Oct 2020
Does anyone know how to combine/merge two surfaces to be used with the function surfl?
I am trying to study mutual shadings using the function surfl. If I plot only one surface, it is quite easy. For instance, by using the following code it is possible to study/identify the mutual shadings created by the light on the function ripples [1]:
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
s = [-45 30];
k = [.65 .4 .3 10];
sl = surfl(X,Y,Z,s,k);
Nevertheless, I still did not figure out how to do it when there are two surfaces. For instance, in the following code I have two surfaces but surfl works only on one surface, the upper one (I have omitted s and k, in the first surfl(X,Y,Z) to see if by specifying those only one time was ok). It looks that the parameters s and k are only related to a single surface. Is there a way to set the ligth that works for both surfaces? Thanks in advance for any suggestion.
s = [0 15];
k = [1 .3 .3 0];
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = zeros(size(X));
surfl(X,Y,Z)
hold on
[X,Y] = meshgrid(1:0.5:10,1:20);
Z(:,:)=1;
surfl(X,Y,Z,s,k)
References

Prabhan Purwar on 23 Oct 2020
Edited: Prabhan Purwar on 23 Oct 2020
Hi,
Following code illustrates the surfl implementation upon multiple surfaces.
1) First implementation explains surfl implementation taking each surface as separate surfaces.
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
s = [-45 30];
k = [.65 .4 .3 10];
surfl(X,Y,Z,s,k); %Surface
surfl(X,Y,Z,s,k)
hold on
surfl(X,Y,20+Z,s,k)
hold off
2) Second implementation explains surfl implementation after combining two surfaces as a single surface.
buffer = nan*ones(1,size(X,2));
X3 =[X;buffer;X];
Y3 =[Y;buffer;Y];
Z3 =[Z;buffer;20+Z];
surfl(X3,Y3,Z3,s,k)
Hope it helps!!
Thanks

Pietro Elia on 26 Oct 2020
thanks a lot for your kind reply!!! Really, appreciated. Nevertheless, even if you combine two surfaces in one surface, surfl works indipentenly on both surfaces. For instance try the next code, the light is almost at the zenith so you should have complete shading on the surface undernath. Nevertheless, both surfaces have the same light intensity. Do you know how and if is it possible to solve this issue?
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
s = [0 80];
k = [.65 .4 .3 10];
buffer = nan*ones(1,size(X,2));
X3 =[X;buffer;X];
Y3 =[Y;buffer;Y];
Z3 =[Z;buffer;2+Z];
surfl(X3,Y3,Z3,s,k)