How can I compute the resolution of a triangular mesh ?

7 ビュー (過去 30 日間)
jiji hr
jiji hr 2016 年 5 月 30 日
コメント済み: jiji hr 2016 年 6 月 8 日
Hi,
I want to compute the resolution of a 3D triangular mesh, that is defined as the median of the length of all edges in this mesh. I have an .obj file that contains vertices and faces, and after extracting them in 2D arrays(vertex, face):
function tabMedian = ComputeMedian_jihad( vertex, face )
%COMPUTEMEDIAN_JIHAD Summary of this function goes here
% Detailed explanation goes here
tabMedian = zeros(1,34817);
j = 0;
for i = 1 : size(face,1)
d1 = (vertex(face(i,1),1) - vertex(face(i,2),1)) * (vertex(face(i,1),1) - vertex(face(i,2),1)) + (vertex(face(i,1),2) - vertex(face(i,2),2))*(vertex(face(i,1),2) - vertex(face(i,2),2)) + (vertex(face(i,1),3) - vertex(face(i,2),3))*(vertex(face(i,1),3) - vertex(face(i,2),3));
d1 = sqrt(d1);
d2 = (vertex(face(i,2),1) - vertex(face(i,3),1))^2 + (vertex(face(i,2),2) - vertex(face(i,3),2))^2 + (vertex(face(i,2),3) - vertex(face(i,3),3))^2 ;
d2 = sqrt(d2);
d3 = (vertex(face(i,3),1) - vertex(face(i,1),1))^2 + (vertex(face(i,3),2) - vertex(face(i,1),2))^2 + (vertex(face(i,3),3) - vertex(face(i,1),3))^2 ;
d3 = sqrt(d3);
j = j + 1;
tabMedian(j) = d1;
tabMedian(j+1) = d2;
tabMedian(j+2) = d3;
end
so what i did is to compute the distance between each 2 vertices from the 3 ones that constain the face. then I stok them in an array.Then I use the matlab function median on the table returned by my function. But the problem here is that there will be a (number of vertices) redundancy.
So I would be grateful if you tell me if this is the good way to compute the resolution of the mesh, and how can I eliminate those redundancies.

採用された回答

KSSV
KSSV 2016 年 5 月 31 日
If you have the nodal connectivity data matrix and coordinates in hand, use the following function: http://in.mathworks.com/matlabcentral/fileexchange/25555-mesh2d-automatic-mesh-generation/content/Mesh2d%20v24/connectivity.m
It gives you the length of all the edges. The code is very effective, fast and takes care of repetition of coordinates nodes.
  1 件のコメント
jiji hr
jiji hr 2016 年 6 月 8 日
Thank you so much for help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by