Hilbert Curve
|
IntroductionThis tutorial follows on from the introduction to Hilbert curves, "Hilbert Curve: Concepts & Implementation". The purpose of this tutorial is to develop examples of Hilbert curves for use with Maya. Figure 1 shows the output of the mel script given in listing 1.
In the Listing 1 (hilbert.mel)
|
Variations of the Hilbert CurveSetting a value for the y coordinate based on absolute difference between the x and z coordinates of a cv, as shown in the following code snippet, generates a pyramid - figure 2. |
if($n <= 0) { float $x = $x0 + ($xi + $yi)/2; float $z = $y0 + ($xj + $yj)/2; float $y = 0; if(abs($z) > abs($x)) $y = 0.5 - abs($z); else $y = 0.5 - abs($x); $y *= 2; // Output the coordinates of the cv $cvs[size($cvs)] = <<$x,$y,$z>>; } |
|
The next variation applies a similiar test to the absolute values of x and z but the result is quite different - figure 3. |
if($n <= 0) { float $x = $x0 + ($xi + $yi)/2; float $z = $y0 + ($xj + $yj)/2; float $y = 0; if(abs($z) < abs($x)) $y = 0.5 - abs($z); else $y = 0.5 - abs($x); $y *= 2; // Output the coordinates of the cv $cvs[size($cvs)] = <<$x,$y,$z>>; } |
|
By setting the y coordinate proportional to the distance of the cv to the origin of the curve a "conical" shape can be produced - figure 4. |
if($n <= 0) { float $x = $x0 + ($xi + $yi)/2; float $z = $y0 + ($xj + $yj)/2; float $y = 0; $y = 0.5 - mag(<<$x,$y,$z>>); $y *= 1.5; // Output the coordinates of the cv $cvs[size($cvs)] = <<$x,$y,$z>>; } |
|
© 2002- Malcolm Kesson. All rights reserved.