How can I compute the resolution of a triangular mesh ?
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
KSSV
le 31 Mai 2016
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!