フィルターのクリア

Plot cylinder symmetry axis

2 ビュー (過去 30 日間)
gaetano mallardo
gaetano mallardo 2019 年 1 月 8 日
コメント済み: Raj Gopal Mishra 2020 年 7 月 26 日
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
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
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 件のコメント
gaetano mallardo
gaetano mallardo 2019 年 1 月 9 日
Thank you for your answer, it was exactly what i was looking for, even if i realised there are more cylinder function. Anyway starting from your code i arrived to a solution.
What i was using it's:
model = cylinderModel(params)
Basing on your code i developed the same solution for my model class and i post it here in case it can help someone in future:
figure()
hold on
plot(model)
hold on
cilindro = model; % just name change
plot3([cilindro.Parameters(1,1) cilindro.Parameters(1,4)], ....
[cilindro.Parameters(1,2) cilindro.Parameters(1,5)], ...
[cilindro.Parameters(1,3) cilindro.Parameters(1,6)],...
':r', 'LineWidth',2)
Star Strider
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 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by