Introduction The web notes by Andrew Cumming of Napier University Edinburgh provide a very good introduction to the Hilbert curve. His pseudo code, slightly modified, is shown in listing 1.

Listing 1 (from Andrew Cumming) procedure hilbert(x, y, xi, xj, yi, yj, n) /* x and y are the coordinates of the bottom left corner */ /* xi & xj are the i & j components of the unit x vector of the frame */ /* similarly yi and yj */ if (n <= 0) then LineTo(x + (xi + yi)/2, y + (xj + yj)/2); else { hilbert(x, y, yi/2, yj/2, xi/2, xj/2, n-1); hilbert(x+xi/2, y+xj/2 , xi/2, xj/2, yi/2, yj/2, n-1); hilbert(x+xi/2+yi/2, y+xj/2+yj/2, xi/2, xj/2, yi/2, yj/2, n-1); hilbert(x+xi/2+yi, y+xj/2+yj, -yi/2,-yj/2, -xi/2, -xj/2, n-1); } end procedure; To fully understand how Andrews recursive function operates is not easy and in order to do so it is necessary to break-down his Hilbert procedure so that the role that each "part" plays in the construction of the curve can be more readily understood. We will begin by looking at the inputs of the Hilbert function.

Inputs In addition to the counter (n) that tracks the level from which the function begins to recursively call itself, there are six other inputs to Andrew's procedure. The first two define the x and y coordinates of an input point that will be used in the calculation of a point on the Hilbert curve. The next 4 values define two vectors. Before we see how they are used we must understand what is meant by the inputs labelled xi, xj, yi and yj. Hopefully, figure 1 will make them clearer.



The large black dot, labelled P, in figure 1 is defined by its x and y coordinates - shown as small dots on the two axes. We can see, from the two arrows, that each dot marks the head of a vector. We might call these the x-vector and the y-vector.

