Divide square faces into triangles

조회 수: 5 (최근 30일)
bbah
bbah 2020년 1월 3일
댓글: bbah 2020년 1월 6일
Hello,
i have a faces matrix and i want to divide it into triangles
e.g. faces is a 100x4 matrix
and i want the same faces as triangles e.g. 123x3 ?
i tried it with the delaunayTriangulation but it distorts my mesh.
thank you

채택된 답변

Matt J
Matt J 2020년 1월 3일
편집: Matt J 2020년 1월 3일
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.
  댓글 수: 3
bbah
bbah 2020년 1월 6일
the way you did it i got only Triangulation = [faces(:,1),faces(:,2),faces(:,3)];
i did it with this loop and it works
for i = 1:length(faces)
first = faces(i,1);
second = faces(i,2);
third = faces(i,3);
fourth = faces(i,4);
first_lines(i,:) = [first second third];
second_lines(i+1,:) = [first third fourth];
end
second_lines(1,:) = [];
Triangulation = zeros(2*length(first_lines),3);
Triangulation(1:2:end-1) = first_lines;
Triangulation(2:2:end) = second_lines;
bbah
bbah 2020년 1월 6일
OR
first_lines = [faces(:,[1,2,3])];
second_lines = [faces(:,[1,3,4])];
faces = zeros(2*length(first_lines),3);
faces(1:2:end-1) = first_lines;
faces(2:2:end) = second_lines;

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2020년 1월 3일
I think you would have to do the following steps in a loop over all the faces,
  1. FInd a 2D coordinate system for the plane passing through each face
  2. Convert the 3D coordinates of each of the faces vertice to 2D coordinates
  3. Do a 2D Delaunay tringulation

카테고리

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