MATLAB: Divide square faces into triangles

dividefacespatch

Hello,
i have a faces matrix and i want to divide it into triangles
e.g. faces is a 100×4 matrix
and i want the same faces as triangles e.g. 123×3 ?
i tried it with the delaunayTriangulation but it distorts my mesh.
thank you

Best Answer

If the vertices of the squares are all pre-ordered in counter-clockwise or clock-wise order, I think you could just do,
Triangulation=[ Faces(:,[1,2,3]) ; Faces(:,[3,4,1])] ;
If the vertices are not pre-ordered, it wouldn't be too difficult to loop through and sort them first.