Animations with POVRAYA MATLAB program was used to write the description of the Hilbert curve in POVRAY syntax. In the program, the Hilbert curve (of degree n) is described by the (x,y,z)-coordinates of the end points of the line segments. The program then writes the POVRAY code needed to generate the connecting edge between the neighboring points.
For each line segment, the LINE macro defined in the POVRAY main input file is invoked. The generated line segment is the union of two circles and a cylinder oriented along the x axis. This object is then rotated into the correct orientation and translated to the starting point. Optionally, the texture of the line (default color is yellow) can be colored according to the (normalized) number of the object, which goes from 0 to 1 along the curve.
Following this great tutorial, the animation is controlled from the .ini file. Be sure to invoke POVRAY with the ini file as input when running the raytracing. (If you run the .pov file, the clock parameter identifying which frame is to be rendered is zero.) The raytracing process writes a number of files with incrementing numbers in the file name.
Here are three consecutive example frames. The increment in the scene's rotation angle is 0.5 degrees.
Make the VideoThe PNG files generated by POVRAY are converted into MP4 video using the command
avconv -framerate 24 -i h%04d.png -b 10000k -f mp4 ../test.mp4This comes with the Ubuntu Precise (12.04 LTS) package libav-tools. Here, h%04d.png means that the files from which the frames are loaded have the form h0001.png, h0002.png, and so on. The conversion process stops once the last file in the sequence has been reached. For a smooth animation, I used a framerate of 24 images per second.
The resulting video can be uploaded to Youtube, for instance. The general guideline is to use the maximum video quality that you can reasonably deliver, as Youtube will convert the uploaded videos anyhow.
This video shows the n=3 Hilbert curve.
It was rendered with 1280x720 image resolution (16:9 aspect ratio).
In total, 720 frames were rendered to give the full 360-degree rotation around the object.
The rendering took 7 hours on an otherwise idle workstation with Intel Xeon E5-2609 processor (4 cores with up to 2.4 GHz, all cores used by POVRAY).
POVRAY version 3.7 was used.
This is a video of a n=2 Hilbert curve was rendered with 640x480 image resolution.
Again, a total of 720 frames was rendered to give the full 360-degree rotation around the object.