• /
• # Rangoli

on 2 Dec 2023
• 7
• 34
• 0
• 0
• 1176
drawframe(48);
function drawframe(f)
del = 0.015;
t = 0:60:360;
xv = cosd(t);
yv = sind(t);
for jj=1:1:2
for i=1:1:6
L = [xv(i) xv(i+1) 0 xv(i)];
M = [yv(i) yv(i+1) 0 yv(i)];
N = [xv(i) 0 xv(i+1) xv(i)];
O = [yv(i) 0 yv(i+1) yv(i)];
switch jj
case 1
xtv{i} = L;
ytv{i} = M;
case 2
xtv{i} = N;
ytv{i} = O;
end
end
figure(1)
axis off
for i=1:f
for j=1:1:numel(xtv)
if i==1
x{j} = xtv{j}; y{j} = ytv{j};
end
for k=1:1:3
m{j}(k) = (y{j}(k+1)-y{j}(k))/(x{j}(k+1)-x{j}(k));
xN{j}(k) = x{j}(k) + sign(x{j}(k+1)-x{j}(k))*del/sqrt(1+m{j}(k)^2);
yN{j}(k) = y{j}(k) + sign(y{j}(k+1)-y{j}(k))*abs(m{j}(k))*del/sqrt(1+m{j}(k)^2);
end
switch jj
case 1
L1{i}{j} = line([x{j}(1)*4,x{j}(2)*4], [y{j}(1)*4, y{j}(2)*4], 'Color', 'c', 'linewidth', .5);
L2{i}{j} = line([x{j}(2)*4,x{j}(3)*4], [y{j}(2)*4, y{j}(3)*4], 'Color', 'm', 'linewidth', .5);
L3{i}{j} = line([x{j}(3)*4,x{j}(1)*4], [y{j}(3)*4, y{j}(1)*4], 'Color', 'k', 'linewidth', .5);
case 2
L1{i}{j} = line([x{j}(1)*4,x{j}(2)*4], [y{j}(1)*4, y{j}(2)*4], 'Color', 'k', 'linewidth', .5);
L2{i}{j} = line([x{j}(2)*4,x{j}(3)*4], [y{j}(2)*4, y{j}(3)*4], 'Color', 'm', 'linewidth', .5);
L3{i}{j} = line([x{j}(3)*4,x{j}(1)*4], [y{j}(3)*4, y{j}(1)*4], 'Color', 'c', 'linewidth', .5);
end
x{j} = [xN{j}, xN{j}(1)];
y{j} = [yN{j}, yN{j}(1)];
end
end
end
end
Monica