1Hilbert(3)            User Contributed Perl Documentation           Hilbert(3)
2
3
4

NAME

6       Math::Curve::Hilbert - Perl Implementation of Hilberts space filling
7       Curve
8

SYNOPSIS

10         use Math::Curve::Hilbert;
11
12         # get object representing 8x8 curve with a step of 10 (i.e. draw 80x80 pixels)
13         my $hilbert = Math::Curve::Hilbert->new( direction=>'up', max=>3, clockwise=>1, step=>10);
14
15         # get a point from coordinates
16         my $point = $hilbert->PointFromCoordinates(20,60);
17
18         # get coordinates from a point
19         my ($x,$y) = $hilbert->CoordinatesFromPoint($point);
20
21
22         # get range(s) from box
23         my @ranges = $hilbert->RangeFromCoordinates($x1,$y1,$x2,$y2);
24
25         #
26         # draw image representing curve
27
28         use GD;
29         # create a new image
30         my $im = new GD::Image(300,300);
31         my $black = $im->colorAllocate(0,0,0);
32         my $blue = $im->colorAllocate(0,0,255);
33
34         my $count = 0;
35         my ($x1,$y1) = $hilbert->CoordinatesFromPoint($count++);
36         while ( ($hilbert->CoordinatesFromPoint($count))[0] ) {
37             my ($x2,$y2) = $hilbert->CoordinatesFromPoint($count++);
38             $im->line($x1,$y1,$x2,$y2,$black);
39             ($x1,$y1) = ($x2,$y2);
40         }
41

DESCRIPTION

43       The Hilbert Curve module provides some useful functions using Hilberts
44       Space-filling Curve. This is handy for things like Dithering,
45       Flattening n-dimensional data, fractals - all kind of things really.
46
47       "A Space Filling Curve is a special fractal curve which has the
48       following basic characteristics:
49         it covers completely an area, a volume or a hyper-volume in a 2-d,
50       3-d or N-d space respectively,
51         each point is visited once and only once (the curve does not cross
52       itself), and
53         neighbor points in the native space are likely to be neighbors in the
54       space filling curve."  definition from Multiple Range Query
55       Optimization in Spatial Databases, Apostolos N. Papadopoulos and Yannis
56       Manolopoulos
57
58       Other space filling curves include The Peano and Morton or Z-order
59       curves. There is also the Hilbert II curve which has an 'S' shape
60       rather than a 'U' shape. The Hilbert curve can also be applied to 3
61       dimensions, but this module only supports 2 dimensions.
62
63       Like most space filling curves, the area must be divided into 2 to the
64       power of N parts, such as 8, 16, 32, etc
65
66   EXPORT
67       None by default.
68

METHODS

70   new
71         # get object representing 8x8 curve with a step of 10 (i.e. draw 80x80 pixels)
72         my $hilbert = Math::Curve::Hilbert->new( direction=>'up', max=>3, clockwise=>1, step=>10);
73
74         direction specifies which direction the curve follows :
75
76         up (clockwise) : up, right, down
77         down (clockwise ) : down, right, up
78         left (clockwise) : left, up, right
79         right (clockwise) : right, down, left
80
81         clockwise specifies if the curve moves clockwise or anti-clockwise, the default is clockwise
82
83         max specifies the size of the grid to plot in powers of 2 - max=>2 would be a 4x4 grid, max=>4 would be 16 x 16 grid
84
85         step specifies how large a step should be (used in drawing the curve), the default is 1
86
87         X and Y allow you to specify a starting X and Y coordinate by passing a reference to a the value
88
89   PointFromCoordinates
90         my $point = $hilbert->PointFromCoordinates(20,60);
91
92   CoordinatesFromPoint
93         my ($x1,$y1) = $hilbert->CoordinatesFromPoint($point);
94
95   RangeFromCoordinates
96         # get range(s) from box
97         my @ranges = $hilbert->RangeFromCoordinates($x1,$y1,$x2,$y2);
98

AUTHOR

100       A. J. Trevena, <teejay@droogs.org>
101

SEE ALSO

103       perl.
104
105       <http://mathworld.wolfram.com/HilbertCurve.html>
106

POD ERRORS

108       Hey! The above document had some coding errors, which are explained
109       below:
110
111       Around line 48:
112           Non-ASCII character seen before =encoding in ''. Assuming UTF-8
113
114
115
116perl v5.32.0                      2020-07-28                        Hilbert(3)
Impressum