在 Matlab 中查找顶点并绘制三角形
Find vertices and plot triangle in Matlab
三角形的顶点在tri = [1 2 2 1; 1 2 -2 1]
中给出
我看到 tri 有 4 列和 2 行,但是它们是如何定义顶点的?
tri中定义的顶点是什么以及如何在Matlab中绘制它们?
正如我(希望是正确的)从这些引用不充分的数据中得知的那样,我可以明智地假设这个数组的二维代表两个轴,数据代表 x,y 坐标意味着你的三角形穿过(夸张地)四个verticles : (1,1)
,(2,2)
,(2,-2)
,(1,1)
其中最后一个是重复的。
您可以使用此命令绘制三角形:
triplot(delaunay(tri(1,1:3),tri(2,1:3)),tri(1,1:3),tri(2,1:3))
在您的 tri
变量中,最后一个顶点与第一个顶点相同。如果您希望在使用 plot
时闭合三角形,这是有道理的。比较以下内容:
tri = [1 2 2; 1 2 -2]; %// just the three vertices
plot(tri(1,:), tri(2,:), 'linewidth', 1)
axis([0 3 -3 3])
tri = [1 2 2 1; 1 2 -2 1]; %// first vertex is repeated to "close" the plot
plot(tri(1,:), tri(2,:), 'linewidth', 1)
axis([0 3 -3 3])
三角形的顶点在tri = [1 2 2 1; 1 2 -2 1]
我看到 tri 有 4 列和 2 行,但是它们是如何定义顶点的?
tri中定义的顶点是什么以及如何在Matlab中绘制它们?
正如我(希望是正确的)从这些引用不充分的数据中得知的那样,我可以明智地假设这个数组的二维代表两个轴,数据代表 x,y 坐标意味着你的三角形穿过(夸张地)四个verticles : (1,1)
,(2,2)
,(2,-2)
,(1,1)
其中最后一个是重复的。
您可以使用此命令绘制三角形:
triplot(delaunay(tri(1,1:3),tri(2,1:3)),tri(1,1:3),tri(2,1:3))
在您的 tri
变量中,最后一个顶点与第一个顶点相同。如果您希望在使用 plot
时闭合三角形,这是有道理的。比较以下内容:
tri = [1 2 2; 1 2 -2]; %// just the three vertices
plot(tri(1,:), tri(2,:), 'linewidth', 1)
axis([0 3 -3 3])
tri = [1 2 2 1; 1 2 -2 1]; %// first vertex is repeated to "close" the plot
plot(tri(1,:), tri(2,:), 'linewidth', 1)
axis([0 3 -3 3])