Plot cylinder symmetry axis
조회 수: 2 (최근 30일)
이전 댓글 표시
I am using the function cylinder to generate a cylinder model. I would like to show the cylinder axis in my plot.
There is a function to rapidly plot the axis or i have to necessary build it and than plot ?
댓글 수: 1
Raj Gopal Mishra
2020년 7월 26일
We can Also plot it with simple Circle patch repeating it for number of times till we get height.
theta=linspace(0,pi,100);
r=1.5; % radius
h=10; %height
x=r*cos(theta);
y=r*sin(theta);
z=zeros(size(x));
while z(1,1)<h,
patch([x -x], [y -y], [z z], 'r')
hold on
z=z+0.1;
end
hold off
view(3)
채택된 답변
Star Strider
2019년 1월 8일
I am not certain what you intend by ‘axis’.
If you just want a line through the axis of the cylinder, try this:
[X,Y,Z] = cylinder;
figure
surf(X, Y, Z)
hold on
plot3([0 0], [0 0], [-1 2], ':r', 'LineWidth',2)
hold off
grid on
Experiment to get the result you want.
댓글 수: 2
Star Strider
2019년 1월 9일
As always, my pleasure.
For reference, the cylinderModel class (link) is part of the Computer Vision System Toolbox (link) that I do not have.
I added that and MATLAB to the ‘Products’ tags.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!