how to project a contour along a surface plane?
Show older comments
How to plot the projection of a function f(x, y, z) onto a plane with normal vector N, passing through P0?
The goal is that the contour lines appear on top of the inclined plane. See code and plot below.
I guess I should use hgtransform on it, but I am getting nowhere.
N = 2:4;
P0 = 5:7;
d = -N*P0';
x = -5:5;
y = x;
[x, y] = meshgrid(x, y);
z = -(N(1).*x + N(2).*y + d)./N(3);
f = sqrt(x.^2 + y.^2 + z.^2)*0.1;
figure;
hold on;
surface(x, y, z);
xlabel("x");
ylabel("y");
zlabel("z");
shading interp;
cb = colorbar;
cb.Label.String = "z";
cb.Limits = [min(z, [], "all") max(z, [], "all")];
M = eye(4);
HGT = hgtransform();
HGT.Matrix = M;
contour(x, y, f, "k", "ShowText", "on", "Parent",HGT);
grid on;
box on;
view(120, 60)
Accepted Answer
More Answers (1)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


