Last active
December 28, 2016 20:24
-
-
Save Thermoflux/4fbf488efd1cd9eb51ba88376305be55 to your computer and use it in GitHub Desktop.
matlab spinning Rectangles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stopped Big red Square from moving around