NAME
Math::PlanePath::MathImageKochSquareflakes -- four-sided Koch snowflakes
SYNOPSIS
use Math::PlanePath::MathImageKochSquareflakes;
my $path = Math::PlanePath::MathImageKochSquareflakes->new;
my ($x, $y) = $path->n_to_xy (123);
DESCRIPTION
In progress.
This is the Koch curve pattern arranged as concentric four-sided snowflakes.
61 10
/ \
63-62 60-59 9
| |
67 64 58 55 8
/ \ / \ / \
69... 66-65 57-56 54-53 7
| |
70 52 6
/ \
71 51 5
\ /
72 50 4
| |
73 15 49 3
/ / \ \
75-74 17-16 14-13 48-47 2
| | | |
76 18 12 46 1
/ / 4---3 \ \
77 19 . | 11 45 Y=0
\ \ 1---2 / /
78 20 10 44 -1
| | |
79-80 5--6 8--9 42-43 -2
\ \ / /
81 7 41 -3
| |
82 40 -4
/ \
83 39 -5
\ /
84 38 -6
|
21-22 24-25 33-34 36-37 -7
\ / \ / \ /
23 26 32 35 -8
| |
27-28 30-31 -9
\ /
29 -10
^
-9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6 7 8 9 10
The innermost square N=1 to N=4 is the initial figure. Its sides expand in the Koch curve pattern in subsequent rings. The initial figure is on X=+/-0.5,Y=+/-0.5 fractions but the points after that are integer X,Y.
Inward
The inward
option can direct the sides inward instead of outward. The shape and side lengths etc are the same.
69-68 66-65 57-56 54-53 7
| \ / \ / \ / |
70 67 64 58 55 52 6
\ | | /
71 63-62 60-59 51 5
/ \ / \
72 61 50 4
| |
73 49 3
\ /
74-75 17-16 14-13 47-48 2
| | \ / | |
76 18 15 3 12 46 1
\ \ 4--3 / /
77 19 |11 45 <- Y=0
/ / 1--2 \ \
78 20 7 10 44 -1
| / \ | |
80-79 5--6 8--9 43-42 -2
/ \
81 41 -3
| |
82 29 40 -4
\ / \ /
83 27-28 30-31 39 -5
/ | | \
84 23 26 32 35 38 -6
/ \ / \ / \ |
21-22 24-25 33-34 36-37 -7
^
-7 -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6 7
Level Ranges
Counting the innermost N=1 to N=4 square as level 0, a given level has
looplen = 4*4^level
many points. The start of a level is therefore N=1 plus preceding loop lengths,
Nstart = 1 + 4*[ 1 + 4 + 4^2 + ... + 4^(level-1) ]
= 1 + 4*(4^level - 1)/3
= (4^(level+1) - 1)/3
and the end similarly as the total loop lengths inclusive, and also simply one less than the next Nstart,
Nend = 4 * [ 1 + ... + 4^level ]
= (4^(level+2) - 4) / 3
= Nstart(level+1) - 1
For example,
level Nstart Nend
0 1 4
1 5 20
2 21 84
3 85 340
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for the behaviour common to all path classes.
$path = Math::PlanePath::MathImageKochSquareflakes->new ()
$path = Math::PlanePath::MathImageKochSquareflakes->new (inward => $bool)
-
Create and return a new path object.
SEE ALSO
Math::PlanePath, Math::PlanePath::KochCurve, Math::PlanePath::KochSnowflakes