Monday, April 10, 2017

Pseudo Hilbert Curve for Arbitrary Rectangular Regions - Part 2

I fixed the problems mentioned in my last blog post about Pseudo Hilbert curves.  When both side of a block are of length divisible by 4 the block is divided into 2x2 sub-blocks.  Each of these blocks are scanned in an appropriate manner to maintain the flow of the parent block.  I won't show all the examples from the paper I'm working from, but the python module I wrote does generate all the example curves.  I can see room for improvement in places but I'm happy with its operation and how fast it works.  After all, perfect is the enemy of good.

The module allows you to specify an rectangular region.  It will then create an in order list of the (x,y) coordinates of the curve and it will create a "2D" list of the length along the curve.  I have some plans for this that I hope workout.

Get the Code!


  1. Hi, can you help me install this module i want to use for your Generating Stippled Images with Spectacular I am a windows user and newbie in python I appreciate any help.

    1. Sure, no problem. I also use Windows and am still learning Python. I used the Anaconda Python installer because it had most of the packages I needed. You might have to install the Shapely module (I think it comes with newer versions of the Anaconda installer).

      You'll also need to tell Windows and Python where the folder containing the PseudoHilbert module is located. You can do this by setting the PYTHONPATH environment variable. More information on that is located here.
      After that you should be able to import PseudoHilbert.

      I you have an issue with auto enumeration statements, just replace every occurrence of "auto()" with a different number. It doesn't matter what the number is, as long as they are different.

      I hope this helps. Let me know how you go. I still struggle setting up all this stuff as well.


Note: Only a member of this blog may post a comment.