how do I make dots move within a circle?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
How do I make certain dots move within a circle? While other dots move outside the circle?
4 comentarios
TADA
el 23 de Mayo de 2022
Editada: TADA
el 23 de Mayo de 2022
something like that maybe?
% radii
r = 1;
rInner = r - 0.1;
rOuter = r + 0.1;
% theta
t = linspace(0, 2*pi);
% animation settings
frameshift = 0.05;
fps = 24;
frameInterval = 1/fps;
numFrames = 500;
% circle data
x = r*cos(t);
y = r*sin(t);
% animation loop
for i = 1:numFrames
% plot the circle
plot(x,y);
axis equal;
hold on;
% calculate the inner/outer dots positions
xout = (rOuter)*cos(t + i * frameshift);
yout = (rOuter)*sin(t + i * frameshift);
xin = (rInner)*cos(t - i * frameshift);
yin = (rInner)*sin(t - i * frameshift);
% plot inner/outer dots
plot(xout, yout, '.');
plot(xin, yin, '.');
% pause until next frame
pause(frameInterval);
% to clear the plot next iteration
hold off;
end
Respuestas (0)
Ver también
Categorías
Más información sobre Animation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!