.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Math::PlanePath::R5DragonCurve 3pm" .TH Math::PlanePath::R5DragonCurve 3pm "2018-03-18" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Math::PlanePath::R5DragonCurve \-\- radix 5 dragon curve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::R5DragonCurve; \& my $path = Math::PlanePath::R5DragonCurve\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This path is a \*(L"\s-1DDUU\*(R"\s0 turn pattern similar in nature to the terdragon but on a square grid and with 5 segments instead of 3. .PP .Vb 11 \& 31\-\-\-\-\-30 27\-\-\-\-\-26 5 \& | | | | \& 32\-\-\-29/33\-\-28/24\-\-\-\-25 4 \& | | \& 35\-\-\-34/38\-\-39/23\-\-\-\-22 11\-\-\-\-\-10 7\-\-\-\-\-\-6 3 \& | | | | | | | \& 36\-\-\-37/41\-\-20/40\-\-21/17\-\-16/12\-\-\-13/9\-\-\-\-8/4\-\-\-\-\-5 2 \& | | | | | | \& \-\-50 47\-\-\-42/46\-\-19/43\-\-\-\-18 15\-\-\-\-\-14 3\-\-\-\-\-\-2 1 \& | | | | | \& 49/53\-\-48/64 45/65\-\-44/68 69 0\-\-\-\-\-\-1 <\-Y=0 \& \& ^ ^ ^ ^ ^ ^ ^ ^ ^ \& \-7 \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 .Ve .PP The name \*(L"R5\*(R" is by Jorg Arndt. The base figure is an \*(L"S\*(R" shape .IX Xref "Arndt, Jorg" .PP .Vb 5 \& 4\-\-\-\-5 \& | \& 3\-\-\-\-2 \& | \& 0\-\-\-\-1 .Ve .PP which then repeats in self-similar style, so N=5 to N=10 is a copy rotated +90 degrees, as per the direction of the N=1 to N=2 segment. .PP .Vb 7 \& 10 7\-\-\-\-6 \& | | | <\- repeat rotated +90 \& 9\-\-\-8,4\-\-\-5 \& | \& 3\-\-\-\-2 \& | \& 0\-\-\-\-1 .Ve .PP Like the terdragon there are no reversals or mirroring. Each replication is the plain base curve. .PP The shape of N=0,5,10,15,20,25 repeats the initial N=0 to N=5, .PP .Vb 9 \& 25 4 \& / \& / 10_\|_ 3 \& / / \-\-\-\-_\|_\|_ \& 20_\|_ / 5 2 \& \-\-\-\-_\|_ / / \& 15 / 1 \& / \& 0 <\-Y=0 \& \& ^ ^ ^ ^ ^ ^ \& \-4 \-3 \-2 \-1 X=0 1 .Ve .PP The curve never crosses itself. The vertices touch at corners like N=4 and N=8 above, but no edges repeat. .SS "Spiralling" .IX Subsection "Spiralling" The first step N=1 is to the right along the X axis and the path then slowly spirals anti-clockwise and progressively fatter. The end of each replication is .PP .Vb 1 \& Nlevel = 5^level .Ve .PP Each such point is at arctan(2/1)=63.43 degrees further around from the previous, .PP .Vb 6 \& Nlevel X,Y angle (degrees) \& \-\-\-\-\-\- \-\-\-\-\- \-\-\-\-\- \& 1 1,0 0 \& 5 2,1 63.4 \& 25 \-3,4 2*63.4 = 126.8 \& 125 \-11,\-2 3*63.4 = 190.3 .Ve .SS "Arms" .IX Subsection "Arms" The curve fills a quarter of the plane and four copies mesh together perfectly rotated by 90, 180 and 270 degrees. The \f(CW\*(C`arms\*(C'\fR parameter can choose 1 to 4 such curve arms successively advancing. .PP \&\f(CW\*(C`arms => 4\*(C'\fR begins as follows. N=0,4,8,12,16,etc is the first arm (the same shape as the plain curve above), then N=1,5,9,13,17 the second, N=2,6,10,14 the third, etc. .PP .Vb 10 \& arms => 4 \& 16/32\-\-\-20/63 \& | \& 21/60 9/56\-\-\-\-5/12\-\-\-\-8/59 \& | | | | \& 17/33\-\-\- 6/13\-\-0/1/2/3\-\-\-4/15\-\-\-19/35 \& | | | | \& 10/57\-\-\-\-7/14\-\-\-11/58 23/62 \& | \& 22/61\-\-\-18/34 .Ve .PP With four arms every X,Y point is visited twice, except the origin 0,0 where all four begin. Every edge between the points is traversed once. .SS "Tiling" .IX Subsection "Tiling" The little \*(L"S\*(R" shapes of the N=0to5 base shape tile the plane with 2x1 bricks and 1x1 holes in the following pattern, .PP .Vb 10 \& +\-\-+\-\-\-\-\-| |\-\-+\-\-+\-\-\-\-\-| |\-\-+\-\-+\-\-\- \& | | | | | | | | | | \& | |\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-| |\-\-\- \& | | | | | | | | | | | \& +\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-+ \& | | | | | | | | | | \& +\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+ \& | | | | | | | | | | | \& \-\-\-| |\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-| | \& | | | | | | | | | | \& \-\-\-+\-\-\-\-\-| |\-\-\-\-\-o\-\-\-\-\-| |\-\-\-\-\-+\-\-\- \& | | | | | | | | | | \& | |\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-| |\-\-\- \& | | | | | | | | | | | \& +\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-+ \& | | | | | | | | | | \& +\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+ \& | | | | | | | | | | | \& \-\-\-| |\-\-\-\-\-+\-\-\-\-\-| |\-\-\-\-\-+\-\-\-\-\-| | \& | | | | | | | | | | \& \-\-\-+\-\-+\-\-| |\-\-\-\-\-+\-\-+\-\-| |\-\-\-\-\-+\-\-+ .Ve .PP This is the curve with each segment N=2mod5 to N=3mod5 omitted. A 2x1 block has 6 edges but the \*(L"S\*(R" traverses just 4 of them. The way the blocks mesh meshes together mean the other 2 edges are traversed by another brick, possibly a brick on another arm of the curve. .PP This tiling is also found for example at .Sp .RS 4 .Sp Or with enlarged square part, .RE .SH "FUNCTIONS" .IX Header "FUNCTIONS" See \*(L"\s-1FUNCTIONS\*(R"\s0 in Math::PlanePath for behaviour common to all path classes. .ie n .IP """$path = Math::PlanePath::R5DragonCurve\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::R5DragonCurve\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::R5DragonCurve->new ()" .PD 0 .ie n .IP """$path = Math::PlanePath::R5DragonCurve\->new (arms => 4)""" 4 .el .IP "\f(CW$path = Math::PlanePath::R5DragonCurve\->new (arms => 4)\fR" 4 .IX Item "$path = Math::PlanePath::R5DragonCurve->new (arms => 4)" .PD Create and return a new path object. .Sp The optional \f(CW\*(C`arms\*(C'\fR parameter can make 1 to 4 copies of the curve, each arm successively advancing. .ie n .IP """($x,$y) = $path\->n_to_xy ($n)""" 4 .el .IP "\f(CW($x,$y) = $path\->n_to_xy ($n)\fR" 4 .IX Item "($x,$y) = $path->n_to_xy ($n)" Return the X,Y coordinates of point number \f(CW$n\fR on the path. Points begin at 0 and if \f(CW\*(C`$n < 0\*(C'\fR then the return is an empty list. .Sp Fractional \f(CW$n\fR gives an X,Y position along a straight line between the integer positions. .ie n .IP """$n = $path\->xy_to_n ($x,$y)""" 4 .el .IP "\f(CW$n = $path\->xy_to_n ($x,$y)\fR" 4 .IX Item "$n = $path->xy_to_n ($x,$y)" Return the point number for coordinates \f(CW\*(C`$x,$y\*(C'\fR. If there's nothing at \&\f(CW\*(C`$x,$y\*(C'\fR then return \f(CW\*(C`undef\*(C'\fR. .Sp The curve can visit an \f(CW\*(C`$x,$y\*(C'\fR twice. The smallest of the these N values is returned. .ie n .IP """@n_list = $path\->xy_to_n_list ($x,$y)""" 4 .el .IP "\f(CW@n_list = $path\->xy_to_n_list ($x,$y)\fR" 4 .IX Item "@n_list = $path->xy_to_n_list ($x,$y)" Return a list of N point numbers for coordinates \f(CW\*(C`$x,$y\*(C'\fR. .Sp The origin 0,0 has \f(CW\*(C`arms_count()\*(C'\fR many N since it's the starting point for each arm. Other points have up to two Ns for a given \f(CW\*(C`$x,$y\*(C'\fR. If arms=4 then every \f(CW\*(C`$x,$y\*(C'\fR except the origin has exactly two Ns. .ie n .IP """$n = $path\->n_start()""" 4 .el .IP "\f(CW$n = $path\->n_start()\fR" 4 .IX Item "$n = $path->n_start()" Return 0, the first N in the path. .SS "Level Methods" .IX Subsection "Level Methods" .ie n .IP """($n_lo, $n_hi) = $path\->level_to_n_range($level)""" 4 .el .IP "\f(CW($n_lo, $n_hi) = $path\->level_to_n_range($level)\fR" 4 .IX Item "($n_lo, $n_hi) = $path->level_to_n_range($level)" Return \f(CW\*(C`(0, 5**$level)\*(C'\fR, or for multiple arms return \f(CW\*(C`(0, $arms * 5**$level + ($arms\-1))\*(C'\fR. .Sp There are 5^level segments in a curve level, so 5^level+1 points numbered from 0. For multiple arms there are arms*(5^level+1) points, numbered from 0 so n_hi = arms*(5^level+1)\-1. .SH "FORMULAS" .IX Header "FORMULAS" Various formulas for boundary length, area, and more, can be found in the author's mathematical write-up .Sp .RS 4 .RE .SS "Turn" .IX Subsection "Turn" At each point N the curve always turns 90 degrees either to the left or right, it never goes straight ahead. As per the code in Jorg Arndt's fxtbook, if N is written in base 5 then the lowest non-zero digit gives the turn .IX Xref "Arndt, Jorg fxtbook" .PP .Vb 6 \& lowest non\-0 digit turn \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\- \& 1 left \& 2 left \& 3 right \& 4 right .Ve .PP At a point N=digit*5^level for digit=1,2,3,4 the turn follows the shape at that digit, so two lefts then two rights, .PP .Vb 7 \& 4*5^k\-\-\-\-5^(k+1) \& | \& | \& 2*5^k\-\-\-\-2*5^k \& | \& | \& 0\-\-\-\-\-\-1*5^k .Ve .PP The first and last unit segments in each level are the same direction, so at those endpoints it's the next level up which gives the turn. .SS "Next Turn" .IX Subsection "Next Turn" The turn at N+1 can be calculated in a similar way but from the lowest non\-4 digit. .PP .Vb 6 \& lowest non\-4 digit turn \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\- \& 0 left \& 1 left \& 2 right \& 3 right .Ve .PP This works simply because in N=...z444 becomes N+1=...(z+1)000 and so the turn at N+1 is given by digit z+1. .SS "Total Turn" .IX Subsection "Total Turn" The direction at N, ie. the total cumulative turn, is given by the direction of each digit when N is written in base 5, .PP .Vb 6 \& digit direction \& 0 0 \& 1 1 \& 2 2 \& 3 1 \& 4 0 \& \& direction = (sum direction for each digit) * 90 degrees .Ve .PP For example N=13 in base 5 is \*(L"23\*(R" so digit=2 direction=2 plus digit=3 direction=1 gives direction=(2+1)*90 = 270 degrees, ie. south. .PP Because there's no reversals etc in the replications there's no state to maintain when considering the digits, just a plain sum of direction for each digit. .SH "OEIS" .IX Header "OEIS" The R5 dragon is in Sloane's Online Encyclopedia of Integer Sequences as, .Sp .RS 4 (etc) .RE .PP .Vb 2 \& A175337 next turn 0=left,1=right \& (n=0 is the turn at N=1) \& \& A006495 level end X, Re(b^k) \& A006496 level end Y, Re(b^k) \& \& A079004 boundary length N=0 to 5^k, skip initial 7,10 \& being 4*3^k \- 2 \& \& A048473 boundary/2 (one side), N=0 to 5^k \& being half whole, 2*3^n \- 1 \& A198859 boundary/2 (one side), N=0 to 25^k \& being even levels, 2*9^n \- 1 \& A198963 boundary/2 (one side), N=0 to 5*25^k \& being odd levels, 6*9^n \- 1 \& \& A052919,A100702 U part boundary length, N=0 to 5^k \& \& A007798 1/2 * area enclosed N=0 to 5^k \& A016209 1/4 * area enclosed N=0 to 5^k \& \& A005058 1/2 * new area N=5^k to N=5^(k+1) \& being area increments, 5^n \- 3^n \& A005059 1/4 * new area N=5^k to N=5^(k+1) \& being area increments, (5^n \- 3^n)/2 \& \& A125831 N middle segment of level k, (5^k\-1)/2 \& A008776 count single\-visited points N=0 to 5^k, being 2*3^k \& A146086 count visited points N=0 to 5^k \& \& A024024 C[k] boundary lengths, 3^k\-k \& A104743 E[k] boundary lengths, 3^k+k \& \& A135518 1/4 * sum distinct abs(n\-other(n)) in level N=0 to 5^k \& \& arms=1 and arms=3 \& A059841 abs(dX), being simply 1,0 repeating \& A000035 abs(dY), being simply 0,1 repeating \& \& arms=4 \& A165211 abs(dY), being 0,1,0,1,1,0,1,0 repeating .Ve .SH "HOUSE OF GRAPHS" .IX Header "HOUSE OF GRAPHS" House of Graphs entries for the R5 dragon curve as a graph include .IP "level=2, " 4 .IX Item "level=2, " .PD 0 .IP "level=3, " 4 .IX Item "level=3, " .PD .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::DragonCurve, Math::PlanePath::TerdragonCurve .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2012, 2013, 2014, 2015, 2016, 2017, 2018 Kevin Ryde .PP This file is part of Math-PlanePath. .PP Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. .PP Math-PlanePath is distributed in the hope that it will be useful, but \&\s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0 See the \s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with Math-PlanePath. If not, see .