Math-PlanePath
view release on metacpan or search on metacpan
lib/Math/PlanePath/BetaOmega.pm view on Meta::CPAN
The curve is named for the two base shapes
Beta Omega
*---* *---*
| | | |
--* * --* *--
|
The beta is made from three betas and an omega sub-parts. The omega is made
from four betas. In each case the sub-parts are suitably rotated,
transposed or reversed, so expanding to
Beta = 3*Beta+Omega Omega = 4*Beta
*---*---*---* *---*---*---*
| | | |
*---* *---* *---* *---*
| | | |
--* * *---* --* * * *--
| | | | | | |
*---* *---* *---* *---*
|
The sub-parts represent successive ever-smaller substitutions. They have
the effect of making the start a beta going alternately up or down. For
this integer version the start direction is kept fixed as a beta going
upwards and the higher levels then alternate up and down from there.
=head2 Level Ranges
Reckoning the initial N=0 to N=3 as level 1, a replication level extends to
Nlevel = 4^level - 1
Xmin = 0
Xmax = 2^level - 1
Ymin = - (4^floor(level/2) - 1) * 2 / 3
= binary 1010...10
Ymax = (4^ceil(level/2) - 1) / 3
= binary 10101...01
height = Ymax - Ymin = 2^level - 1
The Y range increases alternately above and below by a power of 2, so the
result for Ymin and Ymax is a 1 bit going alternately to Ymax and Ymin,
starting with Ymax for level 1.
level Ymin binary Ymax binary
----- -------------- -------------
0 0 0
1 0 0 1 = 1
2 -2 = -10 1 = 01
3 -2 = -010 5 = 101
4 -10 = -1010 5 = 0101
5 -10 = -01010 21 = 10101
6 -42 = -101010 21 = 010101
7 -42 = -0101010 85 = 1010101
The power of 4 divided by 3 formulas above for Ymin/Ymax have the effect of
producing alternating bit patterns like this.
For odd levels -Ymin/height approaches 1/3 and Ymax/height approaches 2/3,
ie. the start point is about 1/3 up the total extent. For even levels it's
the other way around, with -Ymin/height approaching 2/3 and Ymax/height
approaching 1/3.
=head2 Closed Curve
Wierum's idea for the curve is a closed square made from four betas,
*---* *---*
| | | |
* *-- --* *
| |
| |
* *-- --* *
| | | |
*---* *---*
And at the next expansion level
*---*---*---* *---*---*---*
| | | |
*---* *---* *---* *---*
| | | |
*---* * *-- --* * *---*
| | | | | |
*---* *---* *---* *---*
| |
| |
*---* *---* *---* *---*
| | | | | |
*---* * *-- --* * *---*
| | | |
*---* *---* *---* *---*
| | | |
*---*---*---* *---*---*---*
The code here could be used for that by choosing a level and applying four
copies of the path suitably mirrored and offset in X and Y.
For an odd level, the path N=0 to N=4^level-1 here is the top-right quarter,
entering on the left and exiting downwards. For an even level it's the
bottom-right shape instead, exiting upwards. The difference arises because
when taking successively greater detail sub-parts the initial direction
alternates up or down, but in the code here it's kept fixed (as noted
above).
The start point here is also fixed at Y=0, so an offset Ymin must be applied
if say the centre of the sections is to be Y=0 instead of the side entry
point.
=head1 FUNCTIONS
See L<Math::PlanePath/FUNCTIONS> for behaviour common to all path classes.
=over 4
( run in 1.253 second using v1.01-cache-2.11-cpan-df04353d9ac )