How to rotate a circle around y axis in matlab?

28 ビュー (過去 30 日間)
Ashkan Rigi
Ashkan Rigi 2022 年 4 月 30 日
編集済み: Image Analyst 2022 年 4 月 30 日
Hi every body. I have some circles with different radius (r) and I would like to rotate it around y axis. This is my code:
for r=1:10
for teta=1:360
r=1; % radius
C=[0 0];% center
n=0.01;
theta=0:n*pi/360:2*pi; % the angle
m=r*[cos(theta')+C(1) sin(theta')+C(2)]; % the points of circles
R = [cosd(teta) -sind(teta); sind(teta) cosd(teta)]; % rotation matrix
Ry = [cos(teta) sin(teta); -sin(teta) cos(teta)]
point = m';
Circlepointcloud = Ry*point;
axis equal
set(gca,'Visible','off')
ax = gca;
save_name = sprintf('Circlepointcloud_%02d_%03d',r,teta)
save(save_name,'Circlepointcloud')
Name=['Circle' sprintf('Circlepointcloud_%03d_%03d',r,teta) '.jpg'];
exportgraphics(gca,Name,'Resolution',600);
plot(Circlepointcloud(1,:),Circlepointcloud(2,:),'o','color','black')
end
end

採用された回答

Image Analyst
Image Analyst 2022 年 4 月 30 日
編集済み: Image Analyst 2022 年 4 月 30 日
You need to add drawnow at the bottom of the loop so you can see the progress.
You also need to add the center of the circle to the equation and apply the rotation matrix to the CENTER of the circle, not the circle itself because obviously rotating a cirlce about its center will not show any difference. The center should not be at (0,0) or else you won't see any rotation of course.
See attached demos where I rotated an ellipse.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by