Ellipse around Circle problem

1 回表示 (過去 30 日間)
Gashi
Gashi 2022 年 1 月 6 日
コメント済み: Gashi 2022 年 1 月 6 日
Any idea how I could make the ellipses go around the circle to make a flower?
Here's the code:
clf
figure;
t=0:0.01:2*pi;
x=10*cos(t);
y=3*sin(t);
for i=1:12
hold on;
q=[x;y];
e=pi/12*i;
z=[cos(e) -sin(e);sin(e) cos(e)];
k=z*q;
r=k(1,:);
d=k(2,:);
plot(r,d);
axis square;
pause(1);
end
hold on;
drawCircle(0,0,1);
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 1 月 6 日
How does this differ from your earlier questions ?

サインインしてコメントする。

採用された回答

Yusuf Suer Erdem
Yusuf Suer Erdem 2022 年 1 月 6 日
That is the required code below. The red one with the dashed line is the circle and the other ones are the ellipses around it. You could increase the quantity of ellipses by using other type of formulas or you could try to rotate the existing ones.
clc; clear; close all;
C = [0 0] ; % center
a = 2.5 ; % major axis
e = 0.8 ; % eccentricity
b = a*sqrt(1-e^2) ; % minor axis
R = 2; % Radius if cricle
th = linspace(0,2*pi) ;
% Ellipse
xe = C(1)+a*cos(th) ;
ye = C(2)+b*sin(th) ;
% Ellipse
xe2 = C(1)+b*cos(th) ;
ye2 = C(2)+a*sin(th) ;
% Circle
xc = C(1)+R*cos(th) ;
yc = C(2)+R*sin(th) ;
% plot
plot(xe,ye,'b',xe2,ye2,'g',xc,yc,'r--')
axis equal
  4 件のコメント
Yusuf Suer Erdem
Yusuf Suer Erdem 2022 年 1 月 6 日
I changed the codes into that way. And the graph is below. For the missing ellipses, you need to identify the center points and add these ellipses to these points. After you need to rotate them according to the required angle without changing their sizes.
clc; clear; close all;
CC = [0 0] ;
CE = [0 1.5] ;
CE2= [1.5 0] ;
CE3= [0 -1.5];
CE4= [-1.5 0];
a = 0.5 ;
e = 0.8 ;
b = a*sqrt(1-e^2) ;
R = 0.5;
th = linspace(0,2*pi) ;
xe = CE(1)+b*cos(th) ;
ye = CE(2)+a*sin(th) ;
xe2 = CE2(1)+a*cos(th) ;
ye2 = CE2(2)+b*sin(th) ;
xe3 = CE3(1)+b*cos(th) ;
ye3 = CE3(2)+a*sin(th) ;
xe4 = CE4(1)+a*cos(th) ;
ye4 = CE4(2)+b*sin(th) ;
xc = CC(1)+R*cos(th) ;
yc = CC(2)+R*sin(th) ;
plot(xe,ye,'b',xe2,ye2,'g',xe3,ye3,'y',xe4,ye4,'c',xc,yc,'r--')
axis equal
Gashi
Gashi 2022 年 1 月 6 日
Nice! Thank you so much! :)

サインインしてコメントする。

その他の回答 (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