Borrar filtros
Borrar filtros

How can I compute the resolution of a triangular mesh ?

9 visualizaciones (últimos 30 días)
jiji hr
jiji hr el 30 de Mayo de 2016
Comentada: jiji hr el 8 de Jun. de 2016
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.

Respuesta aceptada

KSSV
KSSV el 31 de Mayo de 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.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by