Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several...

40
Hilbert Curves Slide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented by the mathematician David Hilbert about 100 years ago. The slides will be organized as a sequence of images and the mathematical explanation will follow at the end. The Hilbert curves were used as an illustration of the power of recursion in the famous text: Nicklaus Wirth, “Algorithms + Data Structures = Programs”, Prentice- Hall, 1976. The images in this presentation were created in Java using the Java Power Tools developed at Northeastern University in Boston. Copyright 2001, Richard Rasala.

Transcript of Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several...

Page 1: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 1

Introduction to the Hilbert Curves

• This slide sequence will show several different ways to view the recursive Hilbert curves invented by the mathematician David Hilbert about 100 years ago.

• The slides will be organized as a sequence of images and the mathematical explanation will follow at the end.

• The Hilbert curves were used as an illustration of the power of recursion in the famous text: Nicklaus Wirth, “Algorithms + Data Structures = Programs”, Prentice-Hall, 1976.

• The images in this presentation were created in Java using the Java Power Tools developed at Northeastern University in Boston. Copyright 2001, Richard Rasala.

Page 2: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 2

Hilbert Curve at Recursion Level 1

Page 3: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 3

Hilbert Curve at Recursion Level 2

Page 4: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 4

Hilbert Curve at Recursion Level 3

Page 5: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 5

Hilbert Curve at Recursion Level 4

Page 6: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 6

Hilbert Curve at Recursion Level 5

Page 7: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 7

Hilbert Curve at Recursion Level 6

Page 8: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 8

Hilbert Curve at Recursion Level 7

Page 9: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 9

Hilbert Curve at Recursion Level 8

Page 10: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 10

Hilbert Curve at Recursion Level 9

Page 11: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 11

Composite View of Hilbert Curves from Levels 1 to 5

Page 12: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 12

Hilbert at Level 1 Showing North, East, South, West Views

Page 13: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 13

Hilbert at Level 2 Showing North, East, South, West Views

Page 14: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 14

Hilbert at Level 3 Showing North, East, South, West Views

Page 15: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 15

Hilbert at Level 4 Showing North, East, South, West Views

Page 16: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 16

Hilbert at Level 1 as a Visitor to a Planar Tiling

Page 17: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 17

Hilbert at Level 2 as a Visitor to a Planar Tiling

Page 18: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 18

Hilbert at Level 3 as a Visitor to a Planar Tiling

Page 19: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 19

Hilbert at Level 4 as a Visitor to a Planar Tiling

Page 20: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 20

Hilbert at Level 5 as a Visitor to a Planar Tiling

Page 21: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 21

Hilbert at Level 6 as a Visitor to a Planar Tiling

Page 22: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 22

The Base 4 Hilbert Numbering: Level 1

Page 23: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 23

The Base 4 Hilbert Numbering: Level 2

Page 24: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 24

The Base 4 Hilbert Numbering: Level 3

Page 25: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 25

The Base 4 Hilbert Numbering: Level 4

Page 26: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 26

The Base 4 Hilbert Numbering from Levels 1 to 2

Page 27: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 27

The Base 4 Hilbert Numbering from Levels 1 to 3

Page 28: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 28

The Base 4 Hilbert Numbering from Levels 1 to 4

Page 29: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 29

Mathematics of the Hilbert Curves

• The Hilbert Curves were invented by the mathematician David Hilbert about 100 years ago to answer the Space Filling Curves Problem.

• In its simplest version, the Space Filling Curves Problem asks if there exists a continuous function from the unit interval [0, 1] that maps onto the unit square in the plane.

• The answer to this question is Yes.• The sequence of Hilbert curves give a constructive

definition of the function from the unit interval to the unit square. To obtain this function, one must “pass to the limit” as the level N of recursion goes to infinity.

• Is it possible to understand the limiting function that maps the unit interval onto the unit square in a concrete fashion?

• Yes -- Use the base 4 numbering scheme!

Page 30: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 30

Explanation of the Base 4 Numbering Scheme

• For each finite level N of recursion, the Hilbert curve contains 4N points that lie at the centers of a tiling of the unit square into 4N squares.

• Thus, at level 1, there are 4 points; at level 2, there are 16 points; at level 3, there are 64 points; at level 4, there are 256 points; etc.

• The base 4 numbering scheme numbers the 4N points at level N using a sequence of N digits in base 4.

• At level 1, the points are numbered 0, 1, 2, 3.• At level 2, the points are numbered 00, 01, 02, 03, 10,

11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33.• At level 3, all 3 digit sequences abc in base 4 are used.• At level 4, all 4 digit sequences abcd in base 4 are

used.• Etc.

Page 31: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 31

Explanation of the Base 4 Numbering Scheme: Level 1

• Think of the base 4 numbers as the leading digits in the base 4 expansion of a fraction between 0 and 1. This is similar to the “decimal expansion” except that base 4 is used. Let us call the base 4 expansion the “4-mal expansion”.

• Consider the Hilbert curve of level 1 (next slide). The 4 points numbered 0, 1, 2, 3 are centered in 4 squares. We can now say the following about the limiting Hilbert mapping:– All points x in [0, 1] whose 4-mal expansion begins with 0

will map to a point in the square labeled with 0.– All points x in [0, 1] whose 4-mal expansion begins with 1

will map to a point in the square labeled with 1.– All points x in [0, 1] whose 4-mal expansion begins with 2

will map to a point in the square labeled with 2.– All points x in [0, 1] whose 4-mal expansion begins with 3

will map to a point in the square labeled with 3.

Page 32: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 32

Explanation of the Base 4 Numbering Scheme: Level 1

Page 33: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 33

Explanation of the Base 4 Numbering Scheme: Level 2

• Consider the Hilbert curve of level 2 (next slide). The 16 points numbered 00, 01, 02, 03, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33 are centered in 16 squares. We can now say the following about the limiting Hilbert mapping:– All points x in [0, 1] whose 4-mal expansion begins with a

pair of digits ab will map to a point in the square labeled with ab.

– Notice that the squares labeled with ab for some b all lie within the larger square labeled by a at level 1.

Page 34: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 34

Explanation of the Base 4 Numbering Scheme: Level 2

Page 35: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 35

Explanation of the Base 4 Numbering Scheme: Level 3

• Consider the Hilbert curve of level 3 (next slide). The 64 points numbered by sequences abc are centered in 64 squares. We can now say the following about the limiting Hilbert mapping:– All points x in [0, 1] whose 4-mal expansion begins with a

triple of digits abc will map to a point in the square labeled with abc.

– Notice that the squares labeled with abc for some c all lie within the larger square labeled by ab at level 2.

Page 36: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 36

Explanation of the Base 4 Numbering Scheme: Level 3

Page 37: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 37

Explanation of the Base 4 Numbering Scheme: Level 4

• We can now “pass to the limit” in our minds and develop the following rule for specifying the limiting Hilbert mapping.

• To determine the image of a point x in the interval [0, 1] under the limiting Hilbert mapping to within an accuracy of 1/2N in the x and y directions, find the 4-mal expansion of x with N digits: d1d2…dN. Then, the image of x will lie within the square labeled by d1d2…dN when the Hilbert curve of level N is drawn.

• The manner in which increasing the number of 4-mal digits of a number leads to nested squares within the unit square is shown very well by the next slide.

Page 38: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 38

Explanation of the Base 4 Numbering Scheme: Level 4

Page 39: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 39

The Hilbert Mapping on Particular Points

• Looking at the diagrams that show the nesting of squares and the base 4 numbering, it is possible to deduce the image of various points under the Hilbert mapping.

0 0.0000…

Maps to SW corner of the main square

1/12 0.0111…

Maps to the center of the S edge of the main square

1/6 0.0222…

Maps to the center of the main square

1/4 0.1000…

Maps to the center of the W edge of the main square

1/3 0.1111…

Maps to NW corner of the main square

5/12 0.1222…

Maps to the center of the N edge of the main square

1/2 0.2000…

Maps to the center of the main square

7/12 0.2111…

Maps to the center of the N edge of the main square

2/3 0.2222…

Maps to NE corner of the main square

3/4 0.3000…

Maps to the center of the E edge of the main square

5/6 0.3111…

Maps to the center of the main square

11/12 0.3222…

Maps to the center of the S edge of the main square

1 1.0000…

Maps to SE corner of the main square

Page 40: Hilbert CurvesSlide 1 Introduction to the Hilbert Curves This slide sequence will show several different ways to view the recursive Hilbert curves invented.

Hilbert Curves Slide 40

Concluding Remarks

• The Hilbert mapping maps the unit interval onto the unit square but the mapping is not 1-to-1. As shown in the preceding table, several points in the interval map to the center of the main square.

• Hilbert curves can be applied to storing 2-dimensional data in databases. Imagine the planar region of the data divided into a number of small square tiles as in the Hilbert images. Then use the base 4 numbering to define a database key for storing the associated data. The nice property of this key system is that, for most subsets of the region, data that is geographically close will also be physically close in the database. Exceptions to this nice situation occur at places such as the center of the main square at which several branches of the Hilbert curve converge.