Triangular Mesh w/ Known Vertices

2 Ansichten (letzte 30 Tage)
Andy
Andy am 10 Nov. 2011
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?

Antworten (1)

Patrick Kalita
Patrick Kalita am 11 Nov. 2011
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' );

Community Treasure Hunt

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

Start Hunting!

Translated by