Skip to content

Instantly share code, notes, and snippets.

@Thermoflux
Last active December 28, 2016 20:24
Show Gist options
  • Save Thermoflux/4fbf488efd1cd9eb51ba88376305be55 to your computer and use it in GitHub Desktop.
Save Thermoflux/4fbf488efd1cd9eb51ba88376305be55 to your computer and use it in GitHub Desktop.
matlab spinning Rectangles
%% Clean
clear GeomTest;
clc;
clf
cla
%%
h2 = figure();
ax1 = axes(h2);
%ax2 = axes(h2);
axis(5*[-10 10 -10 10]);
j=0;
l=1;
for i = 1:10
hold on;
if(mod(i,2)==0)
r1(j) = rectangle('Parent',ax1,'Position',[-l/2,-l/2,l,l],'EdgeColor','r');
else
j=j+1;
r2(j) = rectangle('Parent',ax1,'Position',[-l/2,-l/2,l,l],'EdgeColor','g');
hold off;
end
l = l*1.4142;
end
%% Rotate
t = hgtransform('Parent',ax1);
set(r1,'Parent',t);
t2 = hgtransform('Parent',ax1);
set(r2,'Parent',t2);
%%
for i = 1:10000
Rot = makehgtform('zrotate',pi*(i/1000));
t.Matrix = Rot;
% r1(5).Position = r1(5).Position +.001;
Rot = makehgtform('zrotate',pi*(i)/1000);
t2.Matrix = Rot';
drawnow;
% pause(0.001);
end
@Thermoflux
Copy link
Author

Stopped Big red Square from moving around

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment