How to color TriSurf faces ?
이전 댓글 표시
So... I think I understand how each triangular surface gets colored, for example:
% Pretend X, Y, and Z defined above
Tri = delaunay(X,Y);
C = Z;
trisurf(Tri,X,Y,Z,C)
However, it doesn't make sense (to me) why to require C to be the same size as X, Y, or Z. It would make more sense (to me) to write the trisurf function such that the C vector be the same length as Tri so that each face (i.e., defined by the indices in each row of Tri) can be colored according to some property of that specific face (e.g., the dip angle or dip direction of the face)?
Is there a work-around I am not aware of to get the desired effect? Or do I need to make my own copy of the TriSurf function and modify from there?
채택된 답변
추가 답변 (1개)
Darin
2014년 12월 20일
1 개 추천
RE RANT: It all depends on what you are trying to do. One of the most common applications of triangulation is to connect sparse/irregular samples of a continuous function (well water depth, for example) into a surface, which is more convenient with the default behavior. In that case, you can think of the color at the vertices as the sampled value of the function. trisurf with 'Edgecolor', 'none', 'facecolor', 'interp' gives about as credible a version of the raw data as is available. When the points aren't too close together, it can be useful to overlay a plot of dots at the sample points. You could, of course, interpolate the data to a fixed grid (interp2) or form a gridded surface with gridfit to beat down sampling errors, but neither will preserve the full fidelity of the raw samples in a way that scales as you zoom in, which trisurf will. All that said, any default can be a problem when you are trying to do something else. Ergo, options... which might be a bit lacking for your desires.
Curious: What is it you are doing that the Cvalue is a characteristic of the surface, rather than of the verticies (as above)? Depending on the answer, you might be able to use the vornoi diagram dual, which has a vertex to the circumcneter of each face, and triangulates those. In essence, you could interpolate from face to face, rather than from vertex to vertex. This does lose information about the face edges, so it may or may not be suitable for your needs.
카테고리
도움말 센터 및 File Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!