Need help with cylinders
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi everyone. I want to plot and create the intersection of 2 perpendicular cylinders.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160815/image.jpeg)
It should look like this.
Any help would be greatly appreciated!
댓글 수: 2
Walter Roberson
2016년 4월 11일
That does not appear to be a simple plot of perpendicular cylinders to me. Perpendicular cylinders would have a hard boundary not a smoothly curving boundary.
John D'Errico
2016년 4월 11일
편집: John D'Errico
2016년 4월 11일
Walter - I think you are mistaken. That is what the intersection would look like, of two cylinders of the same radius, each aligned with one of the axes.
Visualize one cylinder along the x axis, the other along the y axis. Your point of view is above the cylinders, and off to the side.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/183248/image.jpeg)
As you can see from the cylinders, where they intersect, the surface would look as Mario wants it.
답변 (1개)
Teja Muppirala
2016년 4월 12일
% Make a figure (I like my figures in black)
colordef(figure,'black');
% Draw a parameterized surface
[THETA,Z] = meshgrid(linspace(-pi,pi,9),-1:0.01:1);
L = sqrt(1-Z.^2);
RHO = min( abs(L./cos(THETA)) , abs(L./sin(THETA)) ) ;
[X,Y,Z] = pol2cart(THETA,RHO,Z);
h = surf(X,Y,Z,'EdgeAlpha',0.1,'FaceColor',[0.9 0.9 0.9]);
axis equal
axis vis3d
% Add some lights
rng(0);
for n = 1:4
light('Position',randn(1,3),'Color',rand(1,3));
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174070/image.png)
댓글 수: 0
참고 항목
카테고리
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!