I haven't found a way to see things that I plot with plot3
inside a particular plane. For example, I would like to see the projection of all my objects inside a 2-D view, corresponding to the plane x+y+z=1
. Is there any command to do that?
You can achieve this using the view
command, passing in the normal vector to your plane:
view([1,1,1])
In this case (as explained here) we can take the normal vector from the coefficients [a,b,c]
of the equation
ax + by + cz = d
Example when plotting the plane itself:
[x y] = meshgrid(0:0.1:1);
z = 1 - x - y;
surf(x,y,z)
view([1,1,1]); % <-- key line
xlabel('x'); ylabel('y'); zlabel('z');
Moreover, we can plot the normal line which will be invisible from this view as you are looking directly along it!
hold on
plot3( [0 1], [0 1], [-1 1], 'r' )