How can I merge two surfaces?

조회 수: 24 (최근 30일)
Besim Helic
Besim Helic 2015년 4월 25일
댓글: Thomas Seers 2015년 4월 26일
Hi to everyone,
I have to surfaces (created with hold on/off), but I need them to as one surface, to merge them and than that surface combine with one ellipse to become one ruled surface.
I hope my question is clear.. how can I merge two surface, create them as one without using hold on/off?
Thank you

답변 (2개)

Thomas Seers
Thomas Seers 2015년 4월 25일
Assuming you have two sets of vertex lists, pointsA & pointsB, and two sets of face lists, facesA and facesB, you probably want to stack both sets and update the lower face list. The solution is shown in the demo program below:
% create paired surfaces
gridx = repmat(linspace(-1,1,5),5,1);
gridy = repmat(transpose(linspace(-1,1,5)),1,5);
pointsA = [reshape(gridx,5^2,1) reshape(gridy,5^2,1) zeros(5^2,1)+rand(25,1)/10];
pointsB = [reshape(gridx,5^2,1) reshape(gridy,5^2,1) ones(5^2,1)+rand(25,1)/10];
% triangulate
facesA = delaunay(pointsA(:,1), pointsA(:,2));
facesB = delaunay(pointsB(:,1), pointsB(:,2));
% % visualize
trisurf(facesA, pointsA(:,1), pointsA(:,2), pointsA(:,3));
colormap jet % Default color map.
set(gca, 'Position', [0 0 1 1]); % Fill the figure window.
axis equal vis3d; % Set aspect ratio.
shading interp; % Interpolate color across faces.
camlight left; % Add a light over to the left somewhere.
lighting gouraud; % Use decent lighting.
hold on;
% visualize
trisurf(facesB, pointsB(:,1), pointsB(:,2), pointsB(:,3));
colormap jet % Default color map.
set(gca, 'Position', [0 0 1 1]); % Fill the figure window.
axis equal vis3d; % Set aspect ratio.
shading interp; % Interpolate color across faces.
camlight left; % Add a light over to the left somewhere.
lighting gouraud; % Use decent lighting.
pause(2);
% stack the vertex lists
points = vertcat(pointsA, pointsB);
% update the face list
faceUpdate = facesB+max(max(facesA));
faces = vertcat(facesA,faceUpdate);
close(gcf);
% visualize merged surfaces
trisurf(faces, points(:,1), points(:,2), points(:,3));
colormap jet % Default color map.
set(gca, 'Position', [0 0 1 1]); % Fill the figure window.
axis equal vis3d; % Set aspect ratio.
shading interp; % Interpolate color across faces.
camlight left; % Add a light over to the left somewhere.
lighting gouraud; % Use decent lighting.
Hope this helps
Thomas

Besim Helic
Besim Helic 2015년 4월 26일
Thanks for the answer, but it doesn't hit the point (especially not for someone who is beginner in MatLab). It will be clearer maybe when I present my code and problem:
So I have one circular segment and a line: http://pokit.org/get/img/fddf6a866feeada53269091bd137039c.jpg This is created simply by using hold on/off. But, I need them as one surface while I need this surface to make one ruled surface with ellipse in yz-base.
Can I merge this circular segment and a line? Or is there some other way to connect this "body" in xy-base with ellipse in yz-base?
  댓글 수: 2
Thomas Seers
Thomas Seers 2015년 4월 26일
circular segment and a line indicates 2D geometry: I take it that you mean a semi cylinder and a planar surface. Are you are calling meshgrid?
Thomas Seers
Thomas Seers 2015년 4월 26일
BTW you should place comments in the comment box or update your original answer.

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

카테고리

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