Effacer les filtres
Effacer les filtres

I would like to rotate a circle inside another rotating circle.

21 vues (au cours des 30 derniers jours)
Kushal Bollempalli
Kushal Bollempalli le 13 Juil 2023
Modifié(e) : Dyuman Joshi le 17 Juil 2023
I am unable to figure out how to update the centres for smaller circle. The graph should look as shown in image below the code.
r1 = 0.7; % radius of core circle
r2 = 0.7; % radius of inner circle
r3 = r2/3; % radius of smaller circle
r4 = 0.05;
R = r1 + r2*2 ; % radius of bigger circle
LL = 5;
n = 1000; % no. of points to be traced
t = linspace(0,2*pi,n); % running variable
c = [0 0];
t1 = linspace(0,LL,n); % for cycloid
% points to outer create circle
x = c(1) + R*sin(t);
y = c(2) + R*cos(t);
% points to create core circle
xc = c(1) + r1*sin(t);
yc = c(2) + r1*cos(t);
% points to create inner circle
c1 = [r1+r2 0];
xi = c1(1) + r1*sin(t);
yi = c1(2) + r1*cos(t);
% points to create smaller inner circle
c11 = [R-r3 0];
xi1 = c11(1) + r3*sin(t);
yi1 = c11(2) + r3*cos(t);
% tracing point
c123 = [R 0];
x123 = c123(1) + r4*sin(t);
y123 = c123(2) + r4*cos(t);
% equations of motions for inner circle hypocycloid
xh = (R - r2) * cos(t) + r2 * cos((R - r2) * t / r2);
yh = (R - r2) * sin(t) - r2 * sin((R - r2) * t / r2);
% equations of motions for smaller circle hypocycloid
xh1 = (R - r3) * cos(t) + r3 * cos((R - r3) * t / r3);
yh1 = (R - r3) * sin(t) - r3 * sin((R - r3) * t / r3);
% centerX = c(1)+(R - r2) * cos(t); % x-center of rolling circle
% centerY = c(2)+(R - r2) * sin(t); % y-centre of rolling circle
% centerX1 = c1(1)+(r2 - r3) * cos(t); % x-center of smaller rolling circle
% centerY1 = c1(2)+(r2 - r3) * sin(t); % y-centre of smaller rolling circle
plot(x,y,'r') %plotting outer circle
hold on
plot(xc,yc,'g') %plotting core circle
hold on
h = plot(xi,yi,'b'); %plotting inner circle
hold on
h1 = plot(xi1,yi1,'m'); %plotting smaller inner circle
hold on
h2 = plot(x123,y123,'k');
hold on
g = animatedline('Color','k'); % animateed line for hypocycloid
g1 = animatedline('Color','m'); % animateed line for hypocycloid
% c2 = [centerX;centerY]; % centre of rolling circle
% c3 = [centerX1;centerY1]; % centre of smaller rolling circle
for q = 2:length(t)
centerX = c(1)+(R - r2) * cos(t); % x-center of rolling circle
centerY = c(2)+(R - r2) * sin(t); % y-centre of rolling circle
centerX1 = c1(1)+(r2 - r3) * cos(t); % x-center of smaller rolling circle
centerY1 = c1(2)+(r2 - r3) * sin(t); % y-centre of smaller rolling circle
c2 = [centerX;centerY]; % centre of rolling circle
c3 = [centerX1;centerY1];
centerX1 = centerX1(q);
centerY1 = centerY1(q);
% equation of inner circle for change of path
x11 = c2(1,q)+ r2*sin(t);
y11 = c2(2,q) + r2*cos(t);
hold on;
% x21 = c2(1,q)+ r2*sin(t);
% y21 = c2(2,q) + r2*cos(t);
% hold on;
% equation of small inner circle for change of path
x12 = c3(1,q)+ r3*sin(t);
y12 = c3(2,q) + r3*cos(t);
hold on;
% x22 = c3(1,q)+ r3*sin(t);
% y22 = c3(2,q) + r3*cos(t);
% hold on;
set(h,'XData',x11,'YData',y11) ; % animation of inner circle
% set(h,'XData',x21,'YData',y21) ;
set(h1,'XData',x12,'YData',y12) ; % animation of small inner circle
% set(h1,'XData',x22,'YData',y22) ;
axis([-4 4 -4 4])
% animation of hypocycloid path
% addpoints(g,xh(q),yh(q))
% addpoints(g1,xh1(q),yh1(q))
drawnow
end
axis equal
  2 commentaires
Dyuman Joshi
Dyuman Joshi le 13 Juil 2023
What does the radius r4 correspond to?
Kushal Bollempalli
Kushal Bollempalli le 13 Juil 2023
Its just a point to visualise. We can neglect that

Connectez-vous pour commenter.

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 13 Juil 2023
Modifié(e) : Dyuman Joshi le 17 Juil 2023
Given the current values, you will not obtain the pattern present in the posted image.
You will need a bigger core circle to achieve the pattern. I have used a bigger core circle radius here -
%%Bigger core circle radius
r1 = 7; % radius of core circle
r2 = 0.7; % radius of inner circle
r3 = r2/3; % radius of smaller circle
R = r1 + r2*2 ; % radius of bigger circle
n = 100; % no. of points to be traced
t = linspace(0,2*pi,n); % running variable
c = [0 0];
% points to create outer circle
x = c(1) + R*sin(t);
y = c(2) + R*cos(t);
% points to create core circle
xc = c(1) + r1*sin(t);
yc = c(2) + r1*cos(t);
% points to create inner circle
c1 = [r1+r2 0];
xi = c1(1) + r2*sin(t); %Corrected, r2 instead of r1
yi = c1(2) + r2*cos(t); %Corrected, r2 instead of r1
% points to create smaller inner circle
c11 = [R-r3 0];
xi1 = c11(1) + r3*sin(t);
yi1 = c11(2) + r3*cos(t);
plot(x,y,'r') %plotting outer circle
hold on
plot(xc,yc,'g') %plotting core circle
plot(xi,yi,'b') %plotting inner circle
plot(xi1,yi1,'m') %plotting smaller inner circle
%center of the smaller inner circle
plot(c11(1),c11(2),'k*')
%Distance of moving point from the center of rolling circle
d = -(r2-r3);
%Negative for opposite direction of the center line
g = animatedline('Color','k');
%g1 = animatedline('Color','m');
for k=1:numel(t)
%Curve traced by the center of innermost circle
xt = (r1+r2)*cos(t(k)) - d*cos(t(k)*(r1/r2+1));
yt = (r1+r2)*sin(t(k)) - d*sin(t(k)*(r1/r2+1));
addpoints(g,xt,yt)
%Curve traced by center of revolving circle
%xr = (r1+r2)*cos(t(k));
%yr = (r1+r2)*sin(t(k));
%addpoints(g1,xr,yr)
drawnow
end
Edit - You can also plot the curve directly
%Curve traced by the center of innermost circle
xt = (r1+r2)*cos(t) - d*cos(t*(r1/r2+1));
yt = (r1+r2)*sin(t) - d*sin(t*(r1/r2+1));
plot(xt,yt,'k')
  3 commentaires
Dyuman Joshi
Dyuman Joshi le 14 Juil 2023
If my answer helped you solved your problem, please consider accepting it.
Image Analyst
Image Analyst le 14 Juil 2023
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by