NAME
Math::PlanePath::QuadricCurve  eight segment zigzag
SYNOPSIS
use Math::PlanePath::QuadricCurve;
my $path = Math::PlanePath::QuadricCurve>new;
my ($x, $y) = $path>n_to_xy (123);
DESCRIPTION
This is a selfsimilar zigzag of eight segments,
1819 5
 
1617 20 2324 4
   
1514 2122 2526 3
 
111213 292827 2
 
23 109 3031 5859 ... 1
      
01 4 78 32 5657 60 6364 < Y=0
     
56 3334 5554 6162 1
 
373635 515253 2
 
3839 4243 5049 3
   
4041 44 4748 4
 
4546 5
^
X=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
The base figure is the initial N=0 to N=8,
23
 
01 4 78
 
56
It then repeats, turned to follow edge directions, so N=8 to N=16 is the same shape going upwards, then N=16 to N=24 across, N=24 to N=32 downwards, etc.
The result is the base at ever greater scale extending to the right and with wiggly lines making up the segments. The wiggles don't overlap.
Level Ranges
A given replication extends to
Nlevel = 8^level
X = 4^level
Y = 0
Ymax = 4^0 + 4^1 + ... + 4^level # 11...11 in base 4
= (4^(level+1)  1) / 3
Ymin =  Ymax
Turn
The sequence of turns made by the curve is straightforward. In the base 8 (octal) representation of N, the lowest nonzero digit gives the turn
low digit turn (degrees)
 
1 +90
2 90
3 90
4 0
5 +90
6 +90
7 90
When the least significant digit is nonzero it determines the turn, to make the base N=0 to N=8 shape. When the low digit is zero it's instead the next level up, the N=0,8,16,24,etc shape which is in control, applying a turn for the subsequent base part. So for example at N=16 = 20 octal 20 is a turn 90 degrees.
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.
$path = Math::PlanePath::QuadricCurve>new ()

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.
OEIS
Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include
http://oeis.org/A133851 (etc)
A133851 Y at N=2^k, being successive powers 2^j at k=1mod4
SEE ALSO
Math::PlanePath, Math::PlanePath::QuadricIslands, Math::PlanePath::KochCurve
Math::Fractal::Curve  its examples/generator4.pl is this curve
HOME PAGE
http://user42.tuxfamily.org/mathplanepath/index.html
LICENSE
Copyright 2011, 2012, 2013, 2014 Kevin Ryde
This file is part of MathPlanePath.
MathPlanePath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
MathPlanePath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with MathPlanePath. If not, see <http://www.gnu.org/licenses/>.