How can I merge two surfaces?

21 次查看(过去 30 天)
Besim Helic
Besim Helic 2015-4-25
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