Is there a way to get the mesh which the function "surf" produces? By that I mean I need the usual mesh format which is a list of vertices and a list of faces.

 채택된 답변

Mike Garrity
Mike Garrity 2015년 9월 4일

0 개 추천

Yes, the surf2patch command.
[x,y,z] = peaks(10);
h = surf(x,y,z);
[f,v,c] = surf2patch(h);
At this point:
  • v is a 100x3 array containing the 100 vertices
  • f is an 81x4 array containing indices into v for the 81 faces
  • c is an vector of the 100 data values which would be used for coloring the vertices

댓글 수: 1

Albi
Albi 2015년 9월 4일
Exactly what I was looking for. Thank you.

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

추가 답변 (1개)

Adam
Adam 2015년 9월 3일

0 개 추천

If you mean the X, Y and Z meshes that define the surface then the XData, YData and ZData properties of the surface object contain these and the CData contains the colour data for the ZData values.

댓글 수: 3

No, I mean the relation between faces and vertices. For example, if the four 3D points
points= [1 0 0; 2 3 4; 4 5 6; 5 6 9]
are the corners of a square face, that face would be represented as
face = [1,2,3,4]
where the numbers in the face vector represent the row index of its vertices in the points list above. At least, this is the standard method of defining a mesh and I'm assuming matlab internally uses this method too. This is also the format that matlab's trimesh and quadmesh function use too.
Adam
Adam 2015년 9월 3일
I'm not too familiar with mesh definitions, but FaceNormals and VertexNormals seem to be the only other sets of data you can extract from a surface object but they are m-by-n-by-3 arrays.
Albi
Albi 2015년 9월 3일
Yeah, I checked the properties and found nothing I could use. Looking at the surf doc page, I saw that they briefly explain the algorithm behind the surf function. I could write it myself, but it would be nice to have it for free. Looks like surf can be used only for visualization purposes.

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

카테고리

태그

질문:

2015년 9월 3일

댓글:

2015년 9월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by