- /
-
Koch Snowflake
on 5 Oct 2021
- 6
- 30
- 1
- 0
- 240
Q=[0 0;1/3 0;0.5 +sqrt(3)/6;2/3 0;1 0];
M=[1 0;0 1;0 1;-1 0];
x=[0 1 0.5 0];
y=[0 0 sqrt(3)/2 0];
for n=1:5
u = [];
for i=1:length(x)-1
v = [x(i+1)-x(i);y(i+1)-y(i)];
u = [u;Q*reshape(M*v,2,2)+[x(i) y(i)]];
end
x = u(:,1);
y = u(:,2);
end
plot(x,y);
axis equal off;