我试图在matlab中沿z轴绘制两个值min和max。基本上,我对头部的高度感兴趣,因此我想要绘图上的最小值和最大值。 我的方法是首先将 3D 网格投影到 2D 平面上,然后找到沿 z 轴的最小值和最大值(Vertices(:,3))。 我找到了最小值和最大值,但无法绘制它。我知道它与绘图函数中的 [0,1] 或 [1,0] 有关。 请有人帮忙。我还添加了显示我有兴趣绘制哪些点的图。
clc;
clear all;
mesh = readSurfaceMesh("Mesh.ply");
Vertices=mesh.Vertices;
Faces=mesh.Faces;
min=min(Vertices(:,3));
max=max(Vertices(:,3));
figure;
p=patch('Faces',Faces,'Vertices',Vertices);
view(0,0); %Head Depth-Side View
hold("on");
plot([min, min], [0,1], 'ro', 'LineWidth', 2); % I am stuck here
plot([max, max], [1, 0], 'go', 'LineWidth', 2); %I am stuck here
% You don't need the value of the min and max, you need their position
% in the array
[~, posmin] = min(Vertices(:,3));
[~, posMAX] = max(Vertices(:,3));
% Also, Don't call a variable "min" or or "max", you won't be able to
% call the min() and max() functions anymore!
figure;
p=patch('Faces',Faces,'Vertices',Vertices);
view(0,0); %Head Depth-Side View
hold("on");
% Plot the 3D max and min Vertices
plot3(Vertices(posmin,1), Vertices(posmin,2), Vertices(posmin,3), 'ro');
plot3(Vertices(posMAX,1), Vertices(posMAX,2), Vertices(posMAX,3), 'go');