How can I merge two surfaces?
23 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (2 件)
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
0 件のコメント
Besim Helic
2015 年 4 月 26 日
2 件のコメント
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
2015 年 4 月 26 日
BTW you should place comments in the comment box or update your original answer.
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!