Shadow in 3d plot Matlab

Viewed 310

I want to add the shadow/reflection of the trajectory to each side of my 3d plot (2D perspective projection), something like the picture below:

enter image description here

a = 1.;
b = 0.3;  
c = 0.3;

b1 = 0.008;
b2 = 0.008;
b3 = 0.002;

c1 = 0.004;
c2 = 0.0045;

eta = [50 20 20];
F = @(t,y) [a*y(1) - b1*y(1)*y(2)-b2*y(1)*y(3)- b3* y(1)*y(1) ; -b*y(2) + c1*y(1)*y(2); -c*y(3) + c2*y(1)*y(3)];
[t,y] = ode45(F,[0: (300/1000000): 300], eta);
plot3(y(:,1),y(:,2),y(:,3), 'color', 'blue','LineWidth',2)
grid on;
1 Answers

I guess the simplest approach would be to plot lines on the plane of the axes. For instance, in your given example (I assumed a = 0.3 as you did not specify a) plot3 produces this figure:

Original image without shadow

Here is what you wanted to add:

hold on
plot3(0*y(:,1),y(:,2),y(:,3), 'color', 'k','LineWidth',1); % shadow on the Y-Z plane
plot3(y(:,1),0*y(:,2),y(:,3), 'color', 'k','LineWidth',1); % shadow on the X-Z plane
plot3(y(:,1),y(:,2),0*y(:,3), 'color', 'k','LineWidth',1); % shadow on the X-Y plane

which produces a graph like this:

Figure with shadow

FYI, you can also use imagesc to produce shadow for a surface like the example in this page which basically adds a 2D image of a 3D surface on the axes.

Related