How to create a mesh surface from given 3D coordinates?

조회 수: 110 (최근 30일)
Mitchell Ireland
Mitchell Ireland 2020년 4월 11일
답변: Trang Cao 2024년 5월 28일
Hi all,
I've decided to give MATLAB a try for my research project.
I'm trying to create a 3D mesh of given coordinates E, N and elevation.
I can plot all the points using plot3(x,y,z,'.');
Using an XLSX or csv spreadsheet for the datsets I have removed all unnecessary data such as point name and code leaving only E,N and elevation in a 460x3 table.
And using the patch function it does something but not creating the surface as I would like it as a mesh.
I would also like to set some parameters when creating the mesh i.e don't create surface between outside points where distance between those points is greater than say 20m.
Attached is a screenshot of where I am up to.
Kind regards,
Mitch.
  댓글 수: 2
Tommy
Tommy 2020년 4월 11일
Perhaps this gives what you are looking for?
figure
tri = delaunay(x, y);
trimesh(tri, x, y, z);
hold on; plot3(x,y,z,'.')
Mitchell Ireland
Mitchell Ireland 2020년 4월 11일
Thanks Tommy,
That is helpful and creating the surface as i was hoping.
From here I would like to clip out the log triangles on the edges that are say over 20m between points. See red lines drawing on the screenshot below. These would roughly be the triangles to remove. Any idea if i can add this into the function or in the constraints?

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

채택된 답변

KSSV
KSSV 2020년 4월 11일
Two options:
%%structured
xi = unique(x) ; yi = unique(y) ;
[X,Y] = meshgrid(xi,yi) ;
Z = reshape(z,size(X)) ;
figure
surf(X,Y,Z)
%%unstructured
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
figure
trisurf(tri,x,y,z)
  댓글 수: 2
Mitchell Ireland
Mitchell Ireland 2020년 4월 11일
Thanks KSSV,
That is helpful and creating the surface as i was hoping with added shading that is useful in visualisation.
I could not make the structured function work?
From here I would like to clip out the long triangles on the edges that are say over 20m between points. See red lines drawing on the screenshot below. These would roughly be the triangles to remove. Any idea if i can add this into the function or in the constraints?
KSSV
KSSV 2020년 4월 11일
You need to get the boundary nodes and arrange them in an order and use as constraints. Read about delaunayTraingulation. You have option of specifying constraints.

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

추가 답변 (2개)

Dania Ahmed
Dania Ahmed 2022년 3월 14일
편집: Dania Ahmed 2022년 3월 14일
Here you need a 3D constrained delaunay to plot the domain with internal nodes in 3D. MATLAB allows constrained delaunay in 2D only.
If you wanted to plot the boudndary surface; you can use the function "boundary" with a shrink factor of 1 then trisurf the boundary and the points, i.e.
k = boundary(x,y,z,1);
trisurf(k,x,y,z,'Facecolor','red','FaceAlpha',0.5);

Trang Cao
Trang Cao 2024년 5월 28일
Probably you don't need the answer for this anymore but I was just looking for the answer to a similar question, i.e., delaurayTriangulation do not behave well on non-convex shape.
I found alphaShape and then alphaTriangulation.
Hope this may help someone else...

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by