Triangular Mesh w/ Known Vertices

5 次查看(过去 30 天)
Andy
Andy 2011-11-10
I'm working on an image warping project. I need to take a list of vertices, then a list of which vertices belong to which triangle and create a triangular with them. I've been trying to code it but am unable to do it. I've tried using trimesh with node arrays but I can't get it to work. Can anybody point me in the right direction?

回答(1 个)

Patrick Kalita
Patrick Kalita 2011-11-11
If I understand you correctly, you have a list of vertices and an array that specifies how to connect them into triangles. If you want to visualize this, you can supply this information to the patch command. That information can be used to set the patch object's Vertices and Faces properties.
Here's a simple example -- four vertices are being used to construct 2 triangles:
% vertex locations -- each row is an (x,y) pair. It can also
% be an (x,y,z) triple, but I'll do 2D here for simplicity.
vertices = [ 1 1; 2 2; 1 3; 2 4 ]
% This describes how the vertices connected.
tris = [ 1 2 3; 2 4 3 ]
% Make a patch
patch( 'Vertices', vertices, 'Faces', tris, 'FaceColor', 'r' );

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by