How can I merge two surfaces?
조회 수: 24 (최근 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!