<<

GENERAL I ARTICLE Space-filling

ReMittal

In this article some Peano curves are exhibited and some of their recent applications are dis­ cussed. A C++ program to draw the Hilbert approximately is given.

1. Introduction

R C Mittal is an Associate A 'continuous curve' in the plane is usually defined as Professor at the Univer­ the path traced by a moving point (x (t), Y (t)) as t runs sity of Roorkee, Roorkee. He has been teaching over an interval of the real line, where x(-) and y(.) are mathematics and continuous functions. The impression that goes with computer applications for this notion is that such a curve is an one-dimensional the last 20 years. He has object in the plane. So it was an exciting event in the been a National Science history of mathematics when in 1890, the Italian math­ Talent awardee of NCERT in mathematics. ematician Peano constructed a continuous curve which passed through every point in the unit square. Examples of such 'space-filling' curves were later constructed by Hilbert (in 1891), Moore (in 1900), Lebesgue (in 1904), Sierpinski (in 1912) and Schoenberg (in 1938). These have come to be known as Peano curves. In this note, we exhibit some of these curves, give some recent ap­ plications and also give a C.++ program to draw one of these - the - approximately.

2. Some Space-filling Curves

Recall that two sets A and B have the same if there is a one-to-one map from A onto B. It is well­ known that when both A and B are infinite sets, A may be a proper subset of B and still have the same cardinality. In 1878, George Cantor exhibited a one-to­ one map from the unit interval I = [0,1] onto the unit square S = [0, 1] x [0, 1], thus proving that I and Shave the same cardinality.

------~------26 RESONANCE I December 2000 GENERAL I ARTICLE

Can we find such a map from I onto S which is also Using the triadic continuous? (If so, I and S will be topologically homeo­ expansion of the morphic, by their cOlnpactness.) E Netto answered this numbers in [0,1], question in the negative in 1879 (see [1]). It is not dif­ Peano gave n ficult to see this, using the fact that both I and S are explicit connected sets and the removal of a boulldary point from construction of a S does not make it disconnected whereas the removal of continuous map I I an interior point from makes disconnected. from [0,1] onto The next question that arises is whether a continuous [O,1J x [0,1]. map can be found which is not one-to-one but just onto. This was indeed what Peano achieved. Using the triadic expansion of the real nun1bers in I he gave an explicit construction of a continuous Inap from I onto S. For details, see [1]. An example given later by Lebesgue makes use of the standard in I. Recall that any number t in I has a triadic expansion given by t = 00 . L ad3\ where each ai takes one of the values 0,1, or 2. i=1 The Cantor set C can be defined as

00 1 C = {t : t = L ad3 . with ai = °or 2}. i=1

C is now well known as a . Another (geometric) way to arrive at C is the following: from I, first relnove the open middle one-third interval G I = (1/3,2/3) and call what remains as Fl. Thus FI = [0,1/3] U [2/3, 1J. from each of the two intervals in F I , remove their open middle one-third intervals (1/9,2/9) and (7/9,8/9) and call what is left as F2. From each of the four intervals in F2, remove their open middle one-third intervals and call what remains as F3. And so on ad infinitum. What 00 finally remains is the Cantor set C = n Fn. Lebesgue's n=l construction can now be given as follows: for tEe with 00 i t = L ad3 , define i=l

x(t) = (~b2;~1) y(t) = (~~i)

------~------RESONANCE I December 2000 27 GENERAL I ARTICLE

The Cantor set and where bi = ai/2. Any t tJ. C is an interior point of one the Hilbert curve of the deleted open intervals. Define x ( .) and y ( .) as are examples of linear functions in such intervals. Lebesgue showed that t -t (x(t), y(t)) defines a (see [1]). , a topic of great interest in The Peano curve defined by Schoenberg in 1938 makes modern times. use of a periodic function on the real line. Let

for o ::; t ::; 1/3 p(t) = { ~t - 1 for 1/3 ::; t ::; 2/3 for 2/3 ::; t ::; 1

and extend p ( .) to the entire real line by taking p( - t) = p(t) and p(t + 2) = p(t). Define

00 p(32k-2t) 00 p(32k-1t) x(t) = L 2k ' y(t) = L k k=l k=l 2,

for each t E [0: 1]. These infinite series are uniformly convergent and hence x(·) and y(.) are continuous func­ tions. For a proof that the range of I under (x (.), yC)) is the' unit square, see [2]. This space-filling curve was shown to be nowhere differentiable by (3]. However, much of the popularity of space-filling curves is due to the geometric construction given by the great German mathematician David Hilbert in 1891. His ba­ sic idea was that if the unit interval should fill the whole of S, then one-fourth of I will fill a corresponding sub­ square of S of area 1/4 with continuity in neighbouring squares. Next, I and S can be replaced by an interval of length 1/4 and a subsquare of area 1/4, respectively, and the process can be repeated. Thus for each n ~ 1, I and S are subdivided into 4n closed subintervals and 4n closed subsquares, respectively. The first four stages are shown in F'igure 1. At each stage, the centres of the subsquares are joined by consecutive straight lines in the manner indicated in Figure 1. This procedure defines a sequence of continuous functions from I into S. Since the lengths of the sides of the subsquares tend to zero,

-28------~------­ RESONANCE I December 2000 GENERAL I ARTICLE

Figure 1. Fourstages of the Hi/bert curve.

zero, this sequence converges uniformly to a limit func­ tion which is therefore continuous. This limit function is the Hilbert curve. It is clear that the range of this curve It may seem that is the whole of the unit square. Can you locate some space-filling curves points in the unit which have more than one pre-image are mostly an in the unit interval? academic curiosity or have The idea contained in the above construction has be­ recreational come the basis for the generation of fractals, a topic of applications, as great interest in modern times. The Cantor set as well they produce as the Hilbert curve are fractals - see the Classroom pretty pictures. Article in Resonance, Vol. 2 , No.lO, 1997. For more ex­ However, they amples of space-filling curves using the idea of fractals, became important see [4]. roots in 3. Applications of Space-filling Curves Mandelbrot's development of It may seem that space-filling curves are mostly an acad­ fractals as models emic curiosity or have recreational applications, as they of nature. produce pretty pictures. However, they became impor-

-RE-S-O-N-A-N-C-E--I-D-e-ce-m-b-e-r--20-0-0------~------2-9 GENERAL I ARTICLE

In 1991, a novel tant roots in Mandelbrot's development of fractals as digital halftoning Inodels of nature (see [5]). technique with the In nature, the organization of space-filling structures is aid of space-filling one of the fundamental building blocks of living beings. curves was An organ must be supplied with the necessary support­ introduced to ing substances such as water and oxygen. In many cases render a grey these substances will be transported through vessel sys­ scale image

------~------30 RESONANCE I December 2000 GENERAL I ARTICLE

Box 1: Program to draw Hilbert Curve

#include < iostream.h> #include . #include < math.h> #include < conio.h> void move(int .j,int h,int &x, int &y) { if(j== 1) y-=h; else if(j==2) x+=h; else if(j==3} y+=h; else if(j==4) x-=h; lineto(x,y); } void hilbert(int r, int d, int t, int u, int i, int h, int &x, int &y) { if(i >0) { i- -; hilbert ( d,r, u,e ,i,h,x,y); move(r ,h,x,y); hilbert(r,d,t,u,i,h,x,y); move (d,h,x,y); hilbert(r,d,e,u,i,h,x,y); move(e,h,x,y); hilbert (u,t ,d,r ,i,h,x,y); } } void main ( ) { int n,xl,yl; int xO=50,yO= 150,x,y,h= 10,r=2,d=3,t=4, u=l; int driver=DETECT,mode=O; initgraph( &driver ,&mode, " "); count < < "Give the value of n:"; cin»n; x=xO;y=yO; moveto(x,y); hilbert(r,d,t,u,n,h,x,y); getch( ); restorecrtmode; }

-RE-S-O-N-A-N-C-E--I-D-ec-e-m-b-e-r-2-0-0-0------~------~-~ GENERAL I ARTICLE

4. Computer Generation of Space-filling Curves

Several algorithms have been presented for construct­ ing a Hilbert curve. Null [8] was the first to give a non- recursive algorithm to generate Hilbert and other curves. Wirth [9], by seeing the recursive nature of the curves, has given a recursive procedure to draw these curves. For a Hilbert curve, he uses four mutually re­ cursive procedures, each of them having the same struc­ ture but differing in detail. Goldschlager [10] simplified Wirth's approach by replacing the four procedures by a single procedure. This procedure can be explained as follows. Consider a plotter whose pen can move in four directions: V-up, D-down, R-right and L-left. The pen moves by step-length h at a time. The procedure is:

Procedure Hilbert (R, D, L, V : direction, i: integer)

begin

rf'i > 0 then begin

Hilbert (D,R,V,L,i -1);

n10ve (R, R, h);

Hilbert (R, D, L, V, i-I); move (D, D, h);

Hilbert (R,D,L,V,i -1); move (L, L, h);

Hilbert (V, L, D, R, i-I);

end;

end;

Based 011 this algorithm a program in C++ can be writ­ ten. This is given as Box 1. An output of this program for n = 5 is given in Figure 2.

------~------32 RESONANCE I December 2000 GENERAL I ARTICLE

Figure 2. Output of the C++ program for n=5.

Suggested Reading

[1] E W Hobson, Theory ofFunctions of a Real Variable, Vol. 1, pp. 451-458, Dover, New York, 1957. [2] T M Apostol, Mathematical Analysis, Addison Wesley Publishing Company, Reading, Massachusetts, pp. 396-398,1969. [3] J Alsina, The Peano curve of Schoenberg is nowhere differentiable,]. Approx. Theory, Vol. 33, pp. 28-42, 1981. [4] M F Barnsley, Fractals everywhere, Academic Press, Second Edition, 1993. [5] B B Mandelbrot, Fractals: Form, Chance and Dimension, W H Freeman and Co., San Francisco, 1977. [6] L Velho and J Gomes de Miranda, Digital halftoning with space-filling curves, Computer Graphics, Vol. 25, pp. 81-90, 1991. [7] H-O Peitgen, H Jurgens and D Saupe, Chaos and fractals, New frontiers of Science, Springer-Verlag, p.l02, 1992. [8] A Null, Space-filling curves or how to waste time with a plotter, Software Address for Correspondence Practice and Experience, Vol. 1, pp. 403-410, 1971. ReMittal [9] N Wirth,Algorithms + Data Structures =Programs, Prentice-Hall, Eagle­ University of Roorkee wood Cliffs, New Jersey, 1970. Roorkee 247 667, India. [10] L M Goldschlager, Short algorithms for space-filling curves, Software Email : Practice and Experience, Vol. 11, pp. 99-100, 1981. [email protected]

-R-ES-O--N-A-N-C-E--I-D-e-c-e-m-b-e-r--2-00-0------~~&------33--