Spinning Octagon in MATLAB
Code:
fill([-15
-15 10 10],[-15 10 10 -15],'k');
hold
on;
axis([-15
10 -15 10]);
pause(10);
t=0:pi/4:2*pi;
x=5*cos(t);
y=5*sin(t);
a=x(2);
b=y(2);
axis
equal;
hold
on;
for i=1:25
hold
on;
q=[x+a;y+b];
q=q;
e=pi/10*i;
z=[cos(e)
-sin(e);sin(e) cos(e)];
k=z*q;
r=k(1,:)-a;
d=k(2,:)-b;
plot(r,d,'w','linewidth',2);
hold
on;
axis
square;
pause(0.4);
end
Code:
fill([-15
-15 10 10],[-15 10 10 -15],'k');
hold
on;
axis([-15
10 -15 10]);
pause(10);
t=0:pi/4:2*pi;
x=5*cos(t);
y=5*sin(t);
a=x(2);
b=y(2);
axis
equal;
hold
on;
for i=1:25
hold
on;
q=[x+a;y+b];
q=q;
e=pi/10*i;
z=[cos(e)
-sin(e);sin(e) cos(e)];
k=z*q;
r=k(1,:)-a;
d=k(2,:)-b;
plot(r,d,'w','linewidth',2);
hold
on;
axis
square;
pause(0.4);
end
No comments