NAME
Math::PlanePath::MathImageSierpinskiCurveSquared -- Sierpinski curve
SYNOPSIS
use Math::PlanePath::MathImageSierpinskiCurveSquared;
my $path = Math::PlanePath::MathImageSierpinskiCurveSquared->new (arms => 2);
my ($x, $y) = $path->n_to_xy (123);
DESCRIPTION
In progress.
This is a variation on the SierpinskiCurve with squared up diagonal sections.
14 | 84-85
| | |
13 | 82-83 ...
| |
12 | 80-81
| |
11 | 79-78
| |
10 | 68-69 77-76
| | | |
9 | 66-67 70-71 74-75
| | | |
8 | 64-65 72-73
| |
7 | 63-62 55-54
| | | |
6 | 20-21 61-60 57-56 53-52
| | | | | |
5 | 18-19 22-23 59-58 50-51
| | | |
4 | 16-17 24-25 48-49
| | | |
3 | 15-14 27-26 47-46
| | | |
2 | 4--5 13-12 29-28 36-37 45-44
| | | | | | | |
1 | 2--3 6--7 10-11 30-31 34-35 38-39 42-43
| | | | | | | |
Y=0 | 0--1 8--9 32-33 40-41
|
+----------------------------------------------------
^
X=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
The tiling etc is the same as the SierpinskiCurve, but a diagonal part becomes 4 segments instead of 3. So in the following start of the SierpinskiCurve N=0 to N=1 corresponds to N=0 to N=4, and N=2 to N=3 corresponds to N=5 to N=9. The point N=10 (and similar at N=31, N=42, etc) is an extra in between sides at the same angle
7-- 20-
/ |
6 16--
| |
5 15--
\ |
1--2 4 4--5 10-11
/ \ / | | |
0 3 0-- --9
Arms
The optional arms
parameter can give up to eight copies curves, each advancing successively. For example arms => 8
,
..--90 89--.. 7
| |
82-74 73-81 6
| |
58-66 65-57 5
| |
42-50 49-41 4
| |
34-26 25-33 3
| |
... 43-35 18-10 9-17 32-40 .. 2
| | | | | | | |
91-83 59-51 27-19 2 1 16-24 48-56 80-88 1
| | | | | |
75-67 11--3 . 0--8 64-72 <- Y=0
76-68 12--4 7-15 71-79 -1
| | | | | |
92-84 60-52 28-20 5 6 23-31 55-63 87-95 -2
| | | | | | | |
.. 44-36 21-13 14-22 39-47 .. -3
| |
37-29 30-38 -4
| |
45-53 54-46 -5
| |
61-69 70-62 -6
| |
85-77 78-86 -7
| |
..--93 94--.. -8
^
-8 -7 -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6 7
The middle "." is the origin X=0,Y=0. It would be more symmetrical to make the origin the middle of the eight arms, at X=-0.5,Y=-0.5 in the above, but that would give fractional X,Y values. Apply an offset as X+0.5,Y+0.5 if desired.
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for the behaviour common to all path classes.
$path = Math::PlanePath::MathImageSierpinskiCurveSquared->new ()
$path = Math::PlanePath::MathImageSierpinskiCurveSquared->new (arms => 8)
-
Create and return a new path object.
($x,$y) = $path->n_to_xy ($n)
-
Return the X,Y coordinates of point number
$n
on the path. Points begin at 0 and if$n < 0
then the return is an empty list.Fractional positions give an X,Y position along a straight line between the integer positions.
$n = $path->n_start()
-
Return 0, the first N in the path.