NAME
Math::PlanePath::MathImageDragonRounded -- dragon curve with rounded corners
SYNOPSIS
use Math::PlanePath::MathImageDragonRounded;
my $path = Math::PlanePath::MathImageDragonRounded->new;
my ($x, $y) = $path->n_to_xy (123);
DESCRIPTION
This is a version of the dragon or paper folding curve by Heighway, Harter, et al, done with two points per edge and skipping the vertices so as to make rounded corners,
18-17 10--9 6
/ \ / \
19 16 11 8 5
| | | |
20 15 12 7 4
\ \ / \
21-22 14-13 6--5 3
\ \
23 4 2
| |
24 3 1
/ /
34-33 26-25 . 1--2 <- Y=0
/ \ /
35 32 27 -1
| | |
36 31 28 -2
\ \ /
37-38 30-29 45-46 -3
\ / \
39 44 47 -4
| | |
40 43 48 -5
\ / /
41-42 50-49 -6
/
51 -7
|
...
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
-15-14-13-12-11-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1 2 3 ...
Each edge of the curve is on an X or Y multiple of 3 and the two points on the edge are in between at 1 mod 3 and 2 mod 3. For example the N=19 and N=20 are on the X=-9 edge (a multiple of 3), and at Y=4 and Y=5 (which are 1 and 2 mod 3).
The "rounding" of the corners ensures that for example N=15 and N=22 don't touch as they approach X=-6,Y=3. The curve never crosses itself, but the vertices would touch everywhere it bends back towards itself if it wasn't for the rounding.
Arms
The curve traverses a quarter of the plane and four copies mesh together perfectly when rotated by 90, 180 and 270 degrees. The arms
parameter can choose 1 to 4 curve arms, successively advancing. For example arms => 4
gives
37-33 60-... 6
/ \ /
... 41 29 56 5
| | | |
57 45 25 52 4
\ / \ \
53-49 14-10 21-17 48-44 3
/ \ \ \
18 6 13 40 2
| | | |
22 2 9 36 1
/ / /
30-26 7--3 1--5 28-32 <- Y=0
/ / /
34 11 4 24 -1
| | | |
38 15 8 20 -2
\ \ \ /
42-46 19-23 12-16 51-55 -3
\ \ / \
50 27 47 59 -4
| | | |
54 31 43 ... -5
/ \ /
...-58 35-39 -6
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
-6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6
FUNCTIONS
$path = Math::PlanePath::MathImageDragonRounded->new ()
$path = Math::PlanePath::MathImageDragonRounded->new (arms => $aa)
-
Create and return a new path object.
The optional
arms
parameter makes a multi-arm curve. The default is 1 for just one arm. ($x,$y) = $path->n_to_xy ($n)
-
Return the X,Y coordinates of point number
$n
on the path. Points begin at 1 and if$n < 1
then the return is an empty list. $n = $path->n_start()
-
Return 1, the first N in the path.