How to get multiple circles to rotate about a point

4 visualizaciones (últimos 30 días)
Milou Wimart-Clifford
Milou Wimart-Clifford el 7 de En. de 2022
Comentada: Star Strider el 10 de En. de 2022
Hi all!
I am currently working on a project however am having difficulties figuring out how to get multiple shapes to rotate about a point all together at different speeds. In short, im trying to draw a series of circles and get them rotating around a point at different speeds. would anybody be able to give me some pointers on how to do this?
Thanks in advance!

Respuestas (2)

Walter Roberson
Walter Roberson el 7 de En. de 2022
Create one "template" of each different kind of shape. Insert it into an hgtransform() . Now copyobj() the hgtransform() group as many times as you need copies of the object.
Now, for each iteration, loop around through the hgtansform() objects and update their 'Matrix' property, possibly using makehgtform() to do so in a nice way.
You can handle arbitrarily complex objects this way, without having to calculate updated coordinates of each vertex in the object
If you are rotating around a point that is not at (0,0) then subtract the centre of rotation from the coordinates using a 'translate' action, then do the rotation, and then translate back. Note that in makehgtform, the last action in the list of transforms is the one that is done first.

Star Strider
Star Strider el 7 de En. de 2022
Try something like this —
a = linspace(0, 2*pi, 30);
r = 1:3;
cm = colormap(turbo(numel(r)));
figure
for k1 = 1:numel(a)
hold on
for k2 = 1:numel(r)
plot(r(k2)*cos(a(k1)/k2), r(k2)*sin(a(k1)/k2), '-p', 'Color',cm(k2,:), 'MarkerFaceColor',cm(k2,:))
axis('equal')
axis([-5 5 -5 5])
pause(0.1)
drawnow
end
hold off
end
The online Run feature does not allow it to display as it needs to be displayed, so I am not running it here. It needs to be run offline.
.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by