function drawKoch(x0,y0,x1,y1,t)
% DRAWKOCH draws von Koch curve
% between (x0,y0) and (x1,y1).
% t is the number of iterations.
% Usage: drawKoch(x0,y0,x1,y1,t)

% Copyright(C) 2002 Tohru Ikeguchi, All Rights Reserved

% Default value setting
if nargin<1,x0=0;end
if nargin<2,y0=0;end
if nargin<3,x1=1;end
if nargin<4,y1=0;end
if nargin<5,t=0; end

% The base length is L
L=sqrt((x0-x1)^2+(y0-y1)^2);

% Main
% If t=0, just draw a Mexican hat.
if t==0,
  drawChapeau(x0,y0,x1,y1);
% Else, draw 4 small Mexican hats.
else    
%
    theta=pi/3;
    XL=rotation(theta)*[(x1-x0)/3 (y1-y0)/3]'+[(x1+2*x0)/3 (y1+2*y0)/3]';
    XR=rotation(-theta)*[(x1-x0)/3 (y1-y0)/3]'+XL;
%
    hold on
%
    drawKoch...
    drawKoch...
    drawKoch...
    drawKoch...
%
    hold off
end

axis equal
axis off
