Math::Curve::Hilbert

Perl Implementation of Hilberts space filling Curve
Download

Math::Curve::Hilbert Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Aaron James Trevena
  • Publisher web site:
  • http://search.cpan.org/~teejay/

Math::Curve::Hilbert Tags


Math::Curve::Hilbert Description

Perl Implementation of Hilberts space filling Curve Math::Curve::Hilbert is a Perl module that provides some useful functions using Hilberts Space-filling Curve. This is handy for things like Dithering, Flattening n-dimensional data, fractals - all kind of things really."A Space Filling Curve is a special fractal curve which has the following basic characteristics: ­ it covers completely an area, a volume or a hyper-volume in a 2-d, 3-d or N-d space respectively, ­ each point is visited once and only once (the curve does not cross itself), and ­ neighbor points in the native space are likely to be neighbors in the space filling curve." definition from Multiple Range Query Optimization in Spatial Databases, Apostolos N. Papadopoulos and Yannis ManolopoulosOther space filling curves include The Peano and Morton or Z-order curves. There is also the Hilbert II curve which has an 'S' shape rather than a 'U' shape. The Hilbert curve can also be applied to 3 dimensions, but this module only supports 2 dimensions.Like most space filling curves, the area must be divided into 2 to the power of N parts, such as 8, 16, 32, etc.SYNOPSIS use Math::Curve::Hilbert; # get object representing 8x8 curve with a step of 10 (i.e. draw 80x80 pixels) my $hilbert = Math::Curve::Hilbert->new( direction=>'up', max=>3, clockwise=>1, step=>10); # get a point from coordinates my $point = $hilbert->PointFromCoordinates(20,60); # get coordinates from a point my ($x,$y) = $hilbert->CoordinatesFromPoint($point); # get range(s) from box my @ranges = $hilbert->RangeFromCoordinates($x1,$y1,$x2,$y2); # # draw image representing curve use GD; # create a new image my $im = new GD::Image(300,300); my $black = $im->colorAllocate(0,0,0); my $blue = $im->colorAllocate(0,0,255); my $count = 0; my ($x1,$y1) = $hilbert->CoordinatesFromPoint($count++); while ( ($hilbert->CoordinatesFromPoint($count)) ) { my ($x2,$y2) = $hilbert->CoordinatesFromPoint($count++); $im->line($x1,$y1,$x2,$y2,$black); ($x1,$y1) = ($x2,$y2); } Requirements: · Perl


Math::Curve::Hilbert Related Software