필터 지우기
필터 지우기

Triangular surface

조회 수: 9 (최근 30일)
Dougie
Dougie 2012년 5월 3일
I have a surface defined in x, y, z and i am able to get a surface produced using surf(x,y,z). However i want to produce a surface composing of triangles rather than quadrilaterals. The surface is essentially a sphere. And i would like it to be displayed as a triangular surface.
I think i need to use trisurf(tri, x,y,z) but i dont understand the "tri" input. Examples use the delauney(x,y) function but i dont understand what this does and what the alternative for a sphere would be.
Thanks

채택된 답변

Richard Brown
Richard Brown 2012년 5월 4일
Simple example using DelaunayTri. First create a set of points
N = 1000;
theta = 2*pi*rand(N, 1);
phi = acos(2*rand(N, 1) - 1);
x = cos(theta).*sin(phi);
y = sin(theta).*sin(phi);
z = cos(phi);
Mesh the volume using DelaunayTri
Tfull = DelaunayTri(x, y, z);
Find the triangulation on the boundary using freeBoundary
[T, X] = Tfull.freeBoundary();
trisurf(T, X(:, 1), X(:, 2), X(:, 3))
axis equal
  댓글 수: 1
Dougie
Dougie 2012년 5월 5일
Thanks that's great, only i'm using matlab2008 and i dont think trirep and freeBoundary are included in it. Is there a way i can download them?

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

추가 답변 (1개)

Teja Muppirala
Teja Muppirala 2012년 5월 7일
There is also the SURF2PATCH function, which can turn quadrilaterals into triangles. For example:
figure;
[x,y,z] = sphere;
s = surf(x,y,z);
patch(surf2patch(s,'triangles'));
delete(s);
shading faceted;
view(3);
axis equal
Or, without the intermediate call to SURF
figure;
[x,y,z] = sphere;
p = surf2patch(x,y,z,'triangles');
p.facevertexcdata = p.vertices(:,3); %Need this to add color
patch(p);
shading faceted;
view(3);
axis equal

카테고리

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