function C3(N)
close all
figure
axis equal off
hold on
DrawWheel(N)
hold off
figure
axis equal off
hold on
DrawWheel(N)
hold off
shg
function DrawWheel(N)
% Adds a hexagonal color wheel to the current figure window.
% The edge of the wheel has N hexagons.
y = 0;
xStart = -N+1;
for k=0:N-1
% Draw rows k and -k...
x = xStart;
for j=1:2*N-k-1
% Draw the jth tile in row k...
DrawHex(x,y,'y')
% Draw the jth tile in row -k...
DrawHex(x,-y,'y')
x = x+sqrt(3);
end
xStart = xStart+sqrt(3)/2;
y = y+3/2;
end
function DrawHex(xc,yc,c)
% Assumes that "hold" is on and adds a colored hexagon to the current figure
% window. The hexagon is center is (xc,yc) and its edge length is 1.
% Assumes that c is a valid length-3 rgb vector, i.e., 0<=c(i)<=1 for i=1:3.
a = sqrt(3)/2;
b = 1/2;
x = xc + [0 a a 0 -a -a];
y = yc + [1 b -b -1 -b b];
fill(x,y,c)