.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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 .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Math::PlanePath::DragonRounded 3pm" .TH Math::PlanePath::DragonRounded 3pm "2021-01-23" "perl v5.32.0" "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::DragonRounded \-\- dragon curve, with rounded corners .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::DragonRounded; \& my $path = Math::PlanePath::DragonRounded\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a version of the dragon curve by Harter, Heighway, et al, done with two points per edge and skipping vertices so as to make rounded-off corners, .PP .Vb 10 \& 17\-16 9\-\-8 6 \& / \e / \e \& 18 15 10 7 5 \& | | | | \& 19 14 11 6 4 \& \e \e / \e \& 20\-21 13\-12 5\-\-4 3 \& \e \e \& 22 3 2 \& | | \& 23 2 1 \& / / \& 33\-32 25\-24 . 0\-\-1 Y=0 \& / \e / \& 34 31 26 \-1 \& | | | \& 35 30 27 \-2 \& \e \e / \& 36\-37 29\-28 44\-45 \-3 \& \e / \e \& 38 43 46 \-4 \& | | | \& 39 42 47 \-5 \& \e / / \& 40\-41 49\-48 \-6 \& / \& 50 \-7 \& | \& ... \& \& \& ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ \& \-15\-14\-13\-12\-11\-10 \-9 \-8 \-7 \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 ... .Ve .PP The two points on an edge have one of X or Y a multiple of 3 and the other Y or X at 1 mod 3 or 2 mod 3. For example N=19 and N=20 are on the X=\-9 edge (a multiple of 3), and at Y=4 and Y=5 (1 and 2 mod 3). .PP The \*(L"rounding\*(R" of the corners ensures that for example N=13 and N=21 don't touch as they approach X=\-6,Y=3. The curve always approaches vertices like this and never crosses itself. .SS "Arms" .IX Subsection "Arms" The dragon curve fills a quarter of the plane and four copies mesh together rotated by 90, 180 and 270 degrees. The \f(CW\*(C`arms\*(C'\fR parameter can choose 1 to 4 curve arms, successively advancing. For example \f(CW\*(C`arms => 4\*(C'\fR gives .PP .Vb 10 \& 36\-32 59\-... 6 \& / \e / \& ... 40 28 55 5 \& | | | | \& 56 44 24 51 4 \& \e / \e \e \& 52\-48 13\-\-9 20\-16 47\-43 3 \& / \e \e \e \& 17 5 12 39 2 \& | | | | \& 21 1 8 35 1 \& / / / \& 29\-25 6\-\-2 0\-\-4 27\-31 <\- Y=0 \& / / / \& 33 10 3 23 \-1 \& | | | | \& 37 14 7 19 \-2 \& \e \e \e / \& 41\-45 18\-22 11\-15 50\-54 \-3 \& \e \e / \e \& 49 26 46 58 \-4 \& | | | | \& 53 30 42 ... \-5 \& / \e / \& ...\-57 34\-38 \-6 \& \& \& \& ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ \& \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 .Ve .PP With 4 arms like this all 3x3 blocks are visited, using 4 out of 9 points in each. .SS "Midpoint" .IX Subsection "Midpoint" The points of this rounded curve correspond to the \f(CW\*(C`DragonMidpoint\*(C'\fR with a little squish to turn each 6x6 block into a 4x4 block. For instance in the following N=2,3 are pushed to the left, and N=6 through N=11 shift down and squashes up horizontally. .PP .Vb 1 \& DragonRounded DragonMidpoint \& \& 9\-\-8 \& / \e \& 10 7 9\-\-\-8 \& | | | | \& 11 6 10 7 \& / \e | | \& 5\-\-4 <=> \-11 6\-\-\-5\-\-\-4 \& \e | \& 3 3 \& | | \& 2 2 \& / | \& . 0\-\-1 0\-\-\-1 .Ve .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::DragonRounded\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::DragonRounded\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::DragonRounded->new ()" .PD 0 .ie n .IP """$path = Math::PlanePath::DragonRounded\->new (arms => $aa)""" 4 .el .IP "\f(CW$path = Math::PlanePath::DragonRounded\->new (arms => $aa)\fR" 4 .IX Item "$path = Math::PlanePath::DragonRounded->new (arms => $aa)" .PD Create and return a new path object. .Sp The optional \f(CW\*(C`arms\*(C'\fR parameter makes a multi-arm curve. The default is 1 for just one arm. .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. .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, 2 * 2**$level \- 1)\*(C'\fR, or for multiple arms return \f(CW\*(C`(0, $arms * 2 * 2**$level \- 1)\*(C'\fR. .Sp There are 2^level segments comprising the dragon, or arms*2^level when multiple arms. Each has 2 points in this rounded curve, numbered starting from 0. .SH "FORMULAS" .IX Header "FORMULAS" .SS "X,Y to N" .IX Subsection "X,Y to N" The correspondence with the \f(CW\*(C`DragonMidpoint\*(C'\fR noted above allows the method from that module to be used for the rounded \f(CW\*(C`xy_to_n()\*(C'\fR. .PP The correspondence essentially reckons each point on the rounded curve as the midpoint of a dragon curve of one greater level of detail, and segments on 45\-degree angles. .PP The coordinate conversion turns each 6x6 block of \f(CW\*(C`DragonRounded\*(C'\fR to a 4x4 block of \f(CW\*(C`DragonMidpoint\*(C'\fR. There's no rotations or anything. .PP .Vb 2 \& Xmid = X \- floor(X/3) \- Xadj[X%6][Y%6] \& Ymid = Y \- floor(Y/3) \- Yadj[X%6][Y%6] \& \& N = DragonMidpoint n_to_xy of Xmid,Ymid \& \& Xadj[][] is a 6x6 table of 0 or 1 or undef \& Yadj[][] is a 6x6 table of \-1 or 0 or undef .Ve .PP The Xadj,Yadj tables are a handy place to notice X,Y points not on the \&\f(CW\*(C`DragonRounded\*(C'\fR style 4 of 9 points. Or 16 of 36 points since the tables are 6x6. .SH "OEIS" .IX Header "OEIS" Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include the various \f(CW\*(C`DragonCurve\*(C'\fR sequences at even N, and in addition .Sp .RS 4 (etc) .RE .PP .Vb 2 \& A152822 abs(dX), so 0=vertical,1=not, being 1,1,0,1 repeating \& A166486 abs(dY), so 0=horizontal,1=not, being 0,1,1,1 repeating .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::DragonCurve, Math::PlanePath::DragonMidpoint, Math::PlanePath::TerdragonRounded .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde .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 .