.\" 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 3pm" .TH Math::PlanePath 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 \-\- points on a path through the 2\-D plane .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Math::PlanePath; \& # only a base class, see the subclasses for actual operation .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a base class for some mathematical paths which map an integer position \f(CW$n\fR to and from coordinates \f(CW\*(C`$x,$y\*(C'\fR in the 2D plane. .PP The current classes include the following. The intention is that any \&\f(CW\*(C`Math::PlanePath::Something\*(C'\fR is a PlanePath, and supporting base classes or related things are further down like \f(CW\*(C`Math::PlanePath::Base::Xyzzy\*(C'\fR. .PP .Vb 10 \& SquareSpiral four\-sided spiral \& PyramidSpiral square base pyramid \& TriangleSpiral equilateral triangle spiral \& TriangleSpiralSkewed equilateral skewed for compactness \& DiamondSpiral four\-sided spiral, looping faster \& PentSpiral five\-sided spiral \& PentSpiralSkewed five\-sided spiral, compact \& HexSpiral six\-sided spiral \& HexSpiralSkewed six\-sided spiral skewed for compactness \& HeptSpiralSkewed seven\-sided spiral, compact \& AnvilSpiral anvil shape \& OctagramSpiral eight pointed star \& KnightSpiral an infinite knight\*(Aqs tour \& CretanLabyrinth 7\-circuit extended infinitely \& \& SquareArms four\-arm square spiral \& DiamondArms four\-arm diamond spiral \& AztecDiamondRings four\-sided rings \& HexArms six\-arm hexagonal spiral \& GreekKeySpiral square spiral with Greek key motif \& MPeaks "M" shape layers \& \& SacksSpiral quadratic on an Archimedean spiral \& VogelFloret seeds in a sunflower \& TheodorusSpiral unit steps at right angles \& ArchimedeanChords unit chords on an Archimedean spiral \& MultipleRings concentric circles \& PixelRings concentric rings of midpoint pixels \& FilledRings concentric rings of pixels \& Hypot points by distance \& HypotOctant first octant points by distance \& TriangularHypot points by triangular distance \& PythagoreanTree X^2+Y^2=Z^2 by trees \& \& PeanoCurve 3x3 self\-similar quadrant \& PeanoDiagonals across unit squares \& WunderlichSerpentine transpose parts of PeanoCurve \& HilbertCurve 2x2 self\-similar quadrant \& HilbertSides along sides of unit squares \& HilbertSpiral 2x2 self\-similar whole\-plane \& ZOrderCurve replicating Z shapes \& GrayCode Gray code splits \& WunderlichMeander 3x3 "R" pattern quadrant \& BetaOmega 2x2 self\-similar half\-plane \& AR2W2Curve 2x2 self\-similar of four parts \& KochelCurve 3x3 self\-similar of two parts \& DekkingCurve 5x5 self\-similar, edges \& DekkingCentres 5x5 self\-similar, centres \& CincoCurve 5x5 self\-similar \& \& ImaginaryBase replicate in four directions \& ImaginaryHalf half\-plane replicate three directions \& CubicBase replicate in three directions \& SquareReplicate 3x3 replicating squares \& CornerReplicate 2x2 replicating "U" \& LTiling self\-similar L shapes \& DigitGroups digits grouped by zeros \& FibonacciWordFractal turns by Fibonacci word bits \& \& Flowsnake self\-similar hexagonal tile traversal \& FlowsnakeCentres likewise but centres of hexagons \& GosperReplicate self\-similar hexagonal tiling \& GosperIslands concentric island rings \& GosperSide single side or radial \& \& QuintetCurve self\-similar "+" traversal \& QuintetCentres likewise but centres of squares \& QuintetReplicate self\-similar "+" tiling \& \& DragonCurve paper folding \& DragonRounded paper folding rounded corners \& DragonMidpoint paper folding segment midpoints \& AlternatePaper alternating direction folding \& AlternatePaperMidpoint alternating direction folding, midpoints \& TerdragonCurve ternary dragon \& TerdragonRounded ternary dragon rounded corners \& TerdragonMidpoint ternary dragon segment midpoints \& AlternateTerdragon alternate ternary dragon \& R5DragonCurve radix\-5 dragon curve \& R5DragonMidpoint radix\-5 dragon curve midpoints \& CCurve "C" curve \& ComplexPlus base i+realpart \& ComplexMinus base i\-realpart, including twindragon \& ComplexRevolving revolving base i+1 \& \& SierpinskiCurve self\-similar right\-triangles \& SierpinskiCurveStair self\-similar right\-triangles, stair\-step \& HIndexing self\-similar right\-triangles, squared up \& \& KochCurve replicating triangular notches \& KochPeaks two replicating notches \& KochSnowflakes concentric notched 3\-sided rings \& KochSquareflakes concentric notched 4\-sided rings \& QuadricCurve eight segment zig\-zag \& QuadricIslands rings of those zig\-zags \& SierpinskiTriangle self\-similar triangle by rows \& SierpinskiArrowhead self\-similar triangle connectedly \& SierpinskiArrowheadCentres likewise but centres of triangles \& \& Rows fixed\-width rows \& Columns fixed\-height columns \& Diagonals diagonals between X and Y axes \& DiagonalsAlternating diagonals Y to X and back again \& DiagonalsOctant diagonals between Y axis and X=Y centre \& Staircase stairs down from the Y to X axes \& StaircaseAlternating stairs Y to X and back again \& Corner expanding stripes around a corner \& CornerAlternating expanding up and down around a corner \& PyramidRows expanding stacked rows pyramid \& PyramidSides along the sides of a 45\-degree pyramid \& CellularRule cellular automaton by rule number \& CellularRule54 cellular automaton rows pattern \& CellularRule57 cellular automaton (rule 99 mirror too) \& CellularRule190 cellular automaton (rule 246 mirror too) \& UlamWarburton cellular automaton diamonds \& UlamWarburtonQuarter cellular automaton quarter\-plane \& \& DiagonalRationals rationals X/Y by diagonals \& FactorRationals rationals X/Y by prime factorization \& GcdRationals rationals X/Y by rows with GCD integer \& RationalsTree rationals X/Y by tree \& FractionsTree fractions 0new (key=>value, ...)""" 4 .el .IP "\f(CW$path = Math::PlanePath::Foo\->new (key=>value, ...)\fR" 4 .IX Item "$path = Math::PlanePath::Foo->new (key=>value, ...)" Create and return a new path object. Optional key/value parameters may control aspects of the object. .SS "Coordinate Methods" .IX Subsection "Coordinate Methods" .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 X,Y coordinates of point \f(CW$n\fR on the path. If there's no point \&\f(CW$n\fR then the return is an empty list. For example .Sp .Vb 2 \& my ($x,$y) = $path\->n_to_xy (\-123) \& or next; # no negatives in $path .Ve .Sp Paths start from \f(CW\*(C`$path\->n_start()\*(C'\fR below, though some will give a position for N=0 or N=\-0.5 too. .ie n .IP """($dx,$dy) = $path\->n_to_dxdy ($n)""" 4 .el .IP "\f(CW($dx,$dy) = $path\->n_to_dxdy ($n)\fR" 4 .IX Item "($dx,$dy) = $path->n_to_dxdy ($n)" Return the change in X and Y going from point \f(CW$n\fR to point \f(CW\*(C`$n+1\*(C'\fR, or for paths with multiple arms from \f(CW$n\fR to \f(CW\*(C`$n+$arms_count\*(C'\fR (thus advancing one point along the arm of \f(CW$n\fR). .Sp .Vb 5 \& + $n+1 == $next_x,$next_y \& ^ \& | \& | $dx = $next_x \- $x \& + $n == $x,$y $dy = $next_y \- $y .Ve .Sp \&\f(CW$n\fR can be fractional and in that case the dX,dY is from that fractional \&\f(CW$n\fR position to \f(CW\*(C`$n+1\*(C'\fR (or \f(CW\*(C`$n+$arms\*(C'\fR). .Sp .Vb 9 \& frac $n+1 == $next_x,$next_y \& v \& integer *\-\-\-+\-\-\-\- \& | / \& | / \& |/ $dx = $next_x \- $x \& frac + $n == $x,$y $dy = $next_y \- $y \& | \& integer * .Ve .Sp In both cases \f(CW\*(C`n_to_dxdy()\*(C'\fR is the difference \f(CW\*(C`$dx=$next_x\-$x, $dy=$next_y\-$y\*(C'\fR. Currently for most paths it's merely two \f(CW\*(C`n_to_xy()\*(C'\fR calls to calculate the two points, but some paths can calculate a dX,dY with a little less work. .ie n .IP """$rsquared = $path\->n_to_radius ($n)""" 4 .el .IP "\f(CW$rsquared = $path\->n_to_radius ($n)\fR" 4 .IX Item "$rsquared = $path->n_to_radius ($n)" .PD 0 .ie n .IP """$rsquared = $path\->n_to_rsquared ($n)""" 4 .el .IP "\f(CW$rsquared = $path\->n_to_rsquared ($n)\fR" 4 .IX Item "$rsquared = $path->n_to_rsquared ($n)" .PD Return the radial distance R=sqrt(X^2+Y^2) of point \f(CW$n\fR, or the radius squared R^2=X^2+Y^2. If there's no point \f(CW$n\fR then the return is \f(CW\*(C`undef\*(C'\fR. .Sp For a few paths, these might be calculated with less work than \f(CW\*(C`n_to_xy()\*(C'\fR. For example the \f(CW\*(C`SacksSpiral\*(C'\fR is simply R^2=N, or the \f(CW\*(C`MultipleRings\*(C'\fR path with its default step=6 has an integer radius for integer \f(CW$n\fR whereas \&\f(CW\*(C`$x,$y\*(C'\fR are fractional (and so inexact). .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 N point number at 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 .Vb 4 \& my $n = $path\->xy_to_n(20,20); \& if (! defined $n) { \& next; # nothing at this X,Y \& } .Ve .Sp \&\f(CW$x\fR and \f(CW$y\fR can be fractional and the path classes will give an integer \&\f(CW$n\fR which contains \f(CW\*(C`$x,$y\*(C'\fR within a unit square, circle, or intended figure centred on the integer \f(CW$n\fR. .Sp For paths which completely fill the plane there's always an \f(CW$n\fR to return, but for the spread-out paths an \f(CW\*(C`$x,$y\*(C'\fR position may fall in between (no \&\f(CW$n\fR close enough) and give \f(CW\*(C`undef\*(C'\fR. .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 at coordinates \f(CW\*(C`$x,$y\*(C'\fR. If there's nothing at \f(CW\*(C`$x,$y\*(C'\fR then return an empty list. .Sp .Vb 1 \& my @n_list = $path\->xy_to_n(20,20); .Ve .Sp Most paths have just a single N for a given X,Y but some such as \&\f(CW\*(C`DragonCurve\*(C'\fR and \f(CW\*(C`TerdragonCurve\*(C'\fR have multiple N's and this method returns all of them. .Sp Currently all paths have a finite number of N at a given location. It's unspecified what might happen for an infinite list, if that ever occurred. .ie n .IP """@n_list = $path\->n_to_n_list ($n)""" 4 .el .IP "\f(CW@n_list = $path\->n_to_n_list ($n)\fR" 4 .IX Item "@n_list = $path->n_to_n_list ($n)" Return a list of all N point numbers at the location of \f(CW$n\fR. This is equivalent to \f(CW\*(C`xy_to_n_list(n_to_xy($n))\*(C'\fR. .Sp The return list includes \f(CW$n\fR itself. If there is no \f(CW$n\fR in the path then return an empty list. .Sp This function is convenient for paths like \f(CW\*(C`DragonCurve\*(C'\fR or \&\f(CW\*(C`TerdragonCurve\*(C'\fR with double or triple visited points so an N may have other N at the same location. .ie n .IP """$bool = $path\->xy_is_visited ($x,$y)""" 4 .el .IP "\f(CW$bool = $path\->xy_is_visited ($x,$y)\fR" 4 .IX Item "$bool = $path->xy_is_visited ($x,$y)" Return true if \f(CW\*(C`$x,$y\*(C'\fR is visited. This is equivalent to .Sp .Vb 1 \& defined($path\->xy_to_n($x,$y)) .Ve .Sp Some paths cover the plane and for them \f(CW\*(C`xy_is_visited()\*(C'\fR is always true. For others it might be less work to test a point than to calculate its \&\f(CW$n\fR. .ie n .IP """$n = $path\->xyxy_to_n($x1,$y1, $x2,$y2)""" 4 .el .IP "\f(CW$n = $path\->xyxy_to_n($x1,$y1, $x2,$y2)\fR" 4 .IX Item "$n = $path->xyxy_to_n($x1,$y1, $x2,$y2)" .PD 0 .ie n .IP """$n = $path\->xyxy_to_n_either($x1,$y1, $x2,$y2)""" 4 .el .IP "\f(CW$n = $path\->xyxy_to_n_either($x1,$y1, $x2,$y2)\fR" 4 .IX Item "$n = $path->xyxy_to_n_either($x1,$y1, $x2,$y2)" .ie n .IP """@n_list = $path\->xyxy_to_n_list($x1,$y1, $x2,$y2)""" 4 .el .IP "\f(CW@n_list = $path\->xyxy_to_n_list($x1,$y1, $x2,$y2)\fR" 4 .IX Item "@n_list = $path->xyxy_to_n_list($x1,$y1, $x2,$y2)" .ie n .IP """@n_list = $path\->xyxy_to_n_list_either($x1,$y1, $x2,$y2)""" 4 .el .IP "\f(CW@n_list = $path\->xyxy_to_n_list_either($x1,$y1, $x2,$y2)\fR" 4 .IX Item "@n_list = $path->xyxy_to_n_list_either($x1,$y1, $x2,$y2)" .PD Return <$n> which goes from \f(CW\*(C`$x1,$y1\*(C'\fR to \f(CW\*(C`$x2,$y2\*(C'\fR. <$n> is at \f(CW\*(C`$x1,$y1\*(C'\fR and \f(CW\*(C`$n+1\*(C'\fR is at \f(CW\*(C`$x2,$y2\*(C'\fR, or for a multi-arm path \f(CW\*(C`$n+$arms\*(C'\fR, so a step along the same arm. If there's no such \f(CW$n\fR then return \f(CW\*(C`undef\*(C'\fR. .Sp The \f(CW\*(C`either()\*(C'\fR forms allow <$n> in either direction, so \f(CW\*(C`$x1,$y1\*(C'\fR to \&\f(CW\*(C`$x2,$y2\*(C'\fR or the other way \f(CW\*(C`$x2,$y2\*(C'\fR to \f(CW\*(C`$x1,$y1\*(C'\fR. .Sp The \f(CW\*(C`n_list()\*(C'\fR forms return a list of all \f(CW$n\fR going between \f(CW\*(C`$x1,$y1\*(C'\fR and \f(CW\*(C`$x2,$y2\*(C'\fR. For example in \f(CW\*(C`Math::PlanePath::CCurve\*(C'\fR some segments are traversed twice, once in each direction. .Sp The possible N values at each X,Y are determined the same way as for \&\f(CW\*(C`xy_to_n()\*(C'\fR. .ie n .IP """($n_lo, $n_hi) = $path\->rect_to_n_range ($x1,$y1, $x2,$y2)""" 4 .el .IP "\f(CW($n_lo, $n_hi) = $path\->rect_to_n_range ($x1,$y1, $x2,$y2)\fR" 4 .IX Item "($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)" Return a range of N values covering the rectangle with corners at \&\f(CW$x1\fR,\f(CW$y1\fR and \f(CW$x2\fR,\f(CW$y2\fR. The range is inclusive. For example, .Sp .Vb 5 \& my ($n_lo, $n_hi) = $path\->rect_to_n_range (\-5,\-5, 5,5); \& foreach my $n ($n_lo .. $n_hi) { \& my ($x, $y) = $path\->n_to_xy($n) or next; \& print "$n $x,$y"; \& } .Ve .Sp The return might be an over-estimate of the N range required to cover the rectangle. Even if the range is exact, the nature of the path may mean many points between \f(CW$n_lo\fR and \f(CW$n_hi\fR are outside the rectangle. But the range is at least a lower and upper bound on the N values which occur in the rectangle. Classes which guarantee an exact lo/hi say so in their docs. .Sp \&\f(CW$n_hi\fR is usually no more than an extra partial row, revolution, or self-similar level. \f(CW$n_lo\fR might be merely the starting \&\f(CW\*(C`$path\->n_start()\*(C'\fR, which is fine if the origin is in the desired rectangle but away from the origin could actually start higher. .Sp \&\f(CW$x1\fR,\f(CW$y1\fR and \f(CW$x2\fR,\f(CW$y2\fR can be fractional. If they partly overlap some N figures then those N's are included in the return. .Sp If there's no points in the rectangle then the return can be a \*(L"crossed\*(R" range like \f(CW\*(C`$n_lo=1\*(C'\fR, \f(CW\*(C`$n_hi=0\*(C'\fR (which makes a \f(CW\*(C`foreach\*(C'\fR do no loops). But \f(CW\*(C`rect_to_n_range()\*(C'\fR may not always notice there's no points in the rectangle and might instead return an over-estimate. .SS "Descriptive Methods" .IX Subsection "Descriptive Methods" .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 the first N in the path. The start is usually either 0 or 1 according to what is most natural for the path. Some paths have an \&\f(CW\*(C`n_start\*(C'\fR parameter to control the numbering. .Sp Some classes have secret dubious undocumented support for N values below this start (zero or negative), but \f(CW\*(C`n_start()\*(C'\fR is the intended starting point. .ie n .IP """$f = $path\->n_frac_discontinuity()""" 4 .el .IP "\f(CW$f = $path\->n_frac_discontinuity()\fR" 4 .IX Item "$f = $path->n_frac_discontinuity()" Return the fraction of N at which there may be discontinuities in the path. For example if there's a jump in the coordinates between N=7.4999 and N=7.5 then the returned \f(CW$f\fR is 0.5. Or \f(CW$f\fR is 0 if there's a discontinuity between 6.999 and 7.0. .Sp If there's no discontinuities in the path then the return is \f(CW\*(C`undef\*(C'\fR. That means for example fractions between N=7 to N=8 give smooth continuous X,Y values (of some kind). .Sp This is mainly of interest for drawing line segments between N points. If there's discontinuities then the idea is to draw from say N=7.0 to N=7.499 and then another line from N=7.5 to N=8. .ie n .IP """$arms = $path\->arms_count()""" 4 .el .IP "\f(CW$arms = $path\->arms_count()\fR" 4 .IX Item "$arms = $path->arms_count()" Return the number of arms in a \*(L"multi-arm\*(R" path. .Sp For example in \f(CW\*(C`SquareArms\*(C'\fR this is 4 and each arm increments in turn, so the first arm is N=1,5,9,13,etc starting from \f(CW\*(C`$path\->n_start()\*(C'\fR and incrementing by 4 each time. .ie n .IP """$bool = $path\->x_negative()""" 4 .el .IP "\f(CW$bool = $path\->x_negative()\fR" 4 .IX Item "$bool = $path->x_negative()" .PD 0 .ie n .IP """$bool = $path\->y_negative()""" 4 .el .IP "\f(CW$bool = $path\->y_negative()\fR" 4 .IX Item "$bool = $path->y_negative()" .PD Return true if the path extends into negative X coordinates and/or negative Y coordinates respectively. .ie n .IP """$bool = Math::PlanePath::Foo\->class_x_negative()""" 4 .el .IP "\f(CW$bool = Math::PlanePath::Foo\->class_x_negative()\fR" 4 .IX Item "$bool = Math::PlanePath::Foo->class_x_negative()" .PD 0 .ie n .IP """$bool = Math::PlanePath::Foo\->class_y_negative()""" 4 .el .IP "\f(CW$bool = Math::PlanePath::Foo\->class_y_negative()\fR" 4 .IX Item "$bool = Math::PlanePath::Foo->class_y_negative()" .ie n .IP """$bool = $path\->class_x_negative()""" 4 .el .IP "\f(CW$bool = $path\->class_x_negative()\fR" 4 .IX Item "$bool = $path->class_x_negative()" .ie n .IP """$bool = $path\->class_y_negative()""" 4 .el .IP "\f(CW$bool = $path\->class_y_negative()\fR" 4 .IX Item "$bool = $path->class_y_negative()" .PD Return true if any paths made by this class extend into negative X coordinates and/or negative Y coordinates, respectively. .Sp For some classes the X or Y extent may depend on parameter values. .ie n .IP """$n = $path\->x_negative_at_n()""" 4 .el .IP "\f(CW$n = $path\->x_negative_at_n()\fR" 4 .IX Item "$n = $path->x_negative_at_n()" .PD 0 .ie n .IP """$n = $path\->y_negative_at_n()""" 4 .el .IP "\f(CW$n = $path\->y_negative_at_n()\fR" 4 .IX Item "$n = $path->y_negative_at_n()" .PD Return the integer N where X or Y respectively first goes negative, or return \f(CW\*(C`undef\*(C'\fR if it does not go negative (\f(CW\*(C`x_negative()\*(C'\fR or \&\f(CW\*(C`y_negative()\*(C'\fR respectively is false). .ie n .IP """$x = $path\->x_minimum()""" 4 .el .IP "\f(CW$x = $path\->x_minimum()\fR" 4 .IX Item "$x = $path->x_minimum()" .PD 0 .ie n .IP """$y = $path\->y_minimum()""" 4 .el .IP "\f(CW$y = $path\->y_minimum()\fR" 4 .IX Item "$y = $path->y_minimum()" .ie n .IP """$x = $path\->x_maximum()""" 4 .el .IP "\f(CW$x = $path\->x_maximum()\fR" 4 .IX Item "$x = $path->x_maximum()" .ie n .IP """$y = $path\->y_maximum()""" 4 .el .IP "\f(CW$y = $path\->y_maximum()\fR" 4 .IX Item "$y = $path->y_maximum()" .PD Return the minimum or maximum of the X or Y coordinate reached by integer N values in the path. If there's no minimum or maximum then return \f(CW\*(C`undef\*(C'\fR. .ie n .IP """$dx = $path\->dx_minimum()""" 4 .el .IP "\f(CW$dx = $path\->dx_minimum()\fR" 4 .IX Item "$dx = $path->dx_minimum()" .PD 0 .ie n .IP """$dx = $path\->dx_maximum()""" 4 .el .IP "\f(CW$dx = $path\->dx_maximum()\fR" 4 .IX Item "$dx = $path->dx_maximum()" .ie n .IP """$dy = $path\->dy_minimum()""" 4 .el .IP "\f(CW$dy = $path\->dy_minimum()\fR" 4 .IX Item "$dy = $path->dy_minimum()" .ie n .IP """$dy = $path\->dy_maximum()""" 4 .el .IP "\f(CW$dy = $path\->dy_maximum()\fR" 4 .IX Item "$dy = $path->dy_maximum()" .PD Return the minimum or maximum change dX, dY occurring in the path for integer N to N+1. For a multi-arm path the change is N to N+arms so it's the change along the same arm. .Sp Various paths which go by rows have non-decreasing Y. For them \&\f(CW\*(C`dy_minimum()\*(C'\fR is 0. .ie n .IP """$adx = $path\->absdx_minimum()""" 4 .el .IP "\f(CW$adx = $path\->absdx_minimum()\fR" 4 .IX Item "$adx = $path->absdx_minimum()" .PD 0 .ie n .IP """$adx = $path\->absdx_maximum()""" 4 .el .IP "\f(CW$adx = $path\->absdx_maximum()\fR" 4 .IX Item "$adx = $path->absdx_maximum()" .ie n .IP """$ady = $path\->absdy_minimum()""" 4 .el .IP "\f(CW$ady = $path\->absdy_minimum()\fR" 4 .IX Item "$ady = $path->absdy_minimum()" .ie n .IP """$ady = $path\->absdy_maximum()""" 4 .el .IP "\f(CW$ady = $path\->absdy_maximum()\fR" 4 .IX Item "$ady = $path->absdy_maximum()" .PD Return the minimum or maximum change abs(dX) or abs(dY) occurring in the path for integer N to N+1. For a multi-arm path, the change is N to N+arms so it's the change along the same arm. .Sp \&\f(CW\*(C`absdx_maximum()\*(C'\fR is simply max(dXmax,\-dXmin), the biggest change either positive or negative. \f(CW\*(C`absdy_maximum()\*(C'\fR similarly. .Sp \&\f(CW\*(C`absdx_minimum()\*(C'\fR is 0 if dX=0 occurs anywhere in the path, which means any vertical step. If X always changes then \f(CW\*(C`absdx_minimum()\*(C'\fR will be something bigger than 0. \f(CW\*(C`absdy_minimum()\*(C'\fR likewise 0 if any horizontal dY=0, or bigger if Y always changes. .ie n .IP """$sum = $path\->sumxy_minimum()""" 4 .el .IP "\f(CW$sum = $path\->sumxy_minimum()\fR" 4 .IX Item "$sum = $path->sumxy_minimum()" .PD 0 .ie n .IP """$sum = $path\->sumxy_maximum()""" 4 .el .IP "\f(CW$sum = $path\->sumxy_maximum()\fR" 4 .IX Item "$sum = $path->sumxy_maximum()" .PD Return the minimum or maximum values taken by coordinate sum X+Y reached by integer N values in the path. If there's no minimum or maximum then return \&\f(CW\*(C`undef\*(C'\fR. .Sp S=X+Y is an anti-diagonal. A path which is always right and above some anti-diagonal has a minimum. Some paths might be entirely left and below and so have a maximum, though that's unusual. .Sp .Vb 7 \& \e Path always above \& \e | has minimum S=X+Y \& \e| \& \-\-\-o\-\-\-\- \& Path always below |\e \& has maximum S=X+Y | \e \& \e S=X+Y .Ve .ie n .IP """$sum = $path\->sumabsxy_minimum()""" 4 .el .IP "\f(CW$sum = $path\->sumabsxy_minimum()\fR" 4 .IX Item "$sum = $path->sumabsxy_minimum()" .PD 0 .ie n .IP """$sum = $path\->sumabsxy_maximum()""" 4 .el .IP "\f(CW$sum = $path\->sumabsxy_maximum()\fR" 4 .IX Item "$sum = $path->sumabsxy_maximum()" .PD Return the minimum or maximum values taken by coordinate sum abs(X)+abs(Y) reached by integer N values in the path. A minimum always exists but if there's no maximum then return \f(CW\*(C`undef\*(C'\fR. .Sp SumAbs=abs(X)+abs(Y) is sometimes called the \*(L"taxi-cab\*(R" or \*(L"Manhattan\*(R" distance, being how far to travel through a square-grid city to get to X,Y. \&\f(CW\*(C`sumabsxy_minimum()\*(C'\fR is then how close to the origin the path extends. .Sp SumAbs can also be interpreted geometrically as numbering the anti-diagonals of the quadrant containing X,Y, which is equivalent to asking which diamond shape X,Y falls on. \f(CW\*(C`sumabsxy_minimum()\*(C'\fR is then the smallest such diamond reached by the path. .Sp .Vb 9 \& | \& /|\e SumAbs = which diamond X,Y falls on \& / | \e \& / | \e \& \-\-\-\-\-o\-\-\-\-\- \& \e | / \& \e | / \& \e|/ \& | .Ve .ie n .IP """$diffxy = $path\->diffxy_minimum()""" 4 .el .IP "\f(CW$diffxy = $path\->diffxy_minimum()\fR" 4 .IX Item "$diffxy = $path->diffxy_minimum()" .PD 0 .ie n .IP """$diffxy = $path\->diffxy_maximum()""" 4 .el .IP "\f(CW$diffxy = $path\->diffxy_maximum()\fR" 4 .IX Item "$diffxy = $path->diffxy_maximum()" .PD Return the minimum or maximum values taken by coordinate difference X\-Y reached by integer N values in the path. If there's no minimum or maximum then return \f(CW\*(C`undef\*(C'\fR. .Sp D=X\-Y is a leading diagonal. A path which is always right and below such a diagonal has a minimum, for example \f(CW\*(C`HypotOctant\*(C'\fR. A path which is always left and above some diagonal has a maximum D=X\-Y. For example various wedge-like paths such as \f(CW\*(C`PyramidRows\*(C'\fR in its default step=2, and \*(L"upper octant\*(R" paths have a maximum. .Sp .Vb 7 \& / D=X\-Y \& Path always below | / \& has maximum D=X\-Y |/ \& \-\-\-o\-\-\-\- \& /| \& / | Path always above \& / has minimum D=X\-Y .Ve .ie n .IP """$absdiffxy = $path\->absdiffxy_minimum()""" 4 .el .IP "\f(CW$absdiffxy = $path\->absdiffxy_minimum()\fR" 4 .IX Item "$absdiffxy = $path->absdiffxy_minimum()" .PD 0 .ie n .IP """$absdiffxy = $path\->absdiffxy_maximum()""" 4 .el .IP "\f(CW$absdiffxy = $path\->absdiffxy_maximum()\fR" 4 .IX Item "$absdiffxy = $path->absdiffxy_maximum()" .PD Return the minimum or maximum values taken by abs(X\-Y) for integer N in the path. The minimum is 0 or more. If there's maximum then return \f(CW\*(C`undef\*(C'\fR. .Sp abs(X\-Y) can be interpreted geometrically as the distance away from the X=Y diagonal and measured at right-angles to that line. .Sp .Vb 9 \& d=abs(X\-Y) X=Y line \& ^ / \& \e / \& \e/ \& /\e \& / \e \& / \e \& o v \& / d=abs(X\-Y) .Ve .Sp Paths which visit the X=Y line (or approach it as an infimum) have \&\f(CW\*(C`absdiffxy_minimum() = 0\*(C'\fR. Otherwise \f(CW\*(C`absdiffxy_minimum()\*(C'\fR is how close they come to the line. .Sp If the path is entirely below the X=Y line so X>=Y then X\-Y>=0 and \&\f(CW\*(C`absdiffxy_minimum()\*(C'\fR is the same as \f(CW\*(C`diffxy_minimum()\*(C'\fR. If the path is entirely below the X=Y line then \f(CW\*(C`absdiffxy_minimum()\*(C'\fR is \&\f(CW\*(C`\- diffxy_maximum()\*(C'\fR. .ie n .IP """$dsumxy = $path\->dsumxy_minimum()""" 4 .el .IP "\f(CW$dsumxy = $path\->dsumxy_minimum()\fR" 4 .IX Item "$dsumxy = $path->dsumxy_minimum()" .PD 0 .ie n .IP """$dsumxy = $path\->dsumxy_maximum()""" 4 .el .IP "\f(CW$dsumxy = $path\->dsumxy_maximum()\fR" 4 .IX Item "$dsumxy = $path->dsumxy_maximum()" .ie n .IP """$ddiffxy = $path\->ddiffxy_minimum()""" 4 .el .IP "\f(CW$ddiffxy = $path\->ddiffxy_minimum()\fR" 4 .IX Item "$ddiffxy = $path->ddiffxy_minimum()" .ie n .IP """$ddiffxy = $path\->ddiffxy_maximum()""" 4 .el .IP "\f(CW$ddiffxy = $path\->ddiffxy_maximum()\fR" 4 .IX Item "$ddiffxy = $path->ddiffxy_maximum()" .PD Return the minimum or maximum change dSum or dDiffXY occurring in the path for integer N to N+1. For a multi-arm path, the change is N to N+arms so it's the change along the same arm. .ie n .IP """$rsquared = $path\->rsquared_minimum()""" 4 .el .IP "\f(CW$rsquared = $path\->rsquared_minimum()\fR" 4 .IX Item "$rsquared = $path->rsquared_minimum()" .PD 0 .ie n .IP """$rsquared = $path\->rsquared_maximum()""" 4 .el .IP "\f(CW$rsquared = $path\->rsquared_maximum()\fR" 4 .IX Item "$rsquared = $path->rsquared_maximum()" .PD Return the minimum or maximum Rsquared = X^2+Y^2 reached by integer N values in the path. If there's no minimum or maximum then return \f(CW\*(C`undef\*(C'\fR. .Sp Rsquared is always >= 0 so it always has a minimum. The minimum will be more than 0 for paths which don't include the origin X=0,Y=0. .Sp RSquared generally has no maximum since the paths usually extend infinitely in some direction. \f(CW\*(C`rsquared_maximum()\*(C'\fR returns \f(CW\*(C`undef\*(C'\fR in that case. .ie n .IP """($dx,$dy) = $path\->dir_minimum_dxdy()""" 4 .el .IP "\f(CW($dx,$dy) = $path\->dir_minimum_dxdy()\fR" 4 .IX Item "($dx,$dy) = $path->dir_minimum_dxdy()" .PD 0 .ie n .IP """($dx,$dy) = $path\->dir_maximum_dxdy()""" 4 .el .IP "\f(CW($dx,$dy) = $path\->dir_maximum_dxdy()\fR" 4 .IX Item "($dx,$dy) = $path->dir_maximum_dxdy()" .PD Return a vector which is the minimum or maximum angle taken by a step integer N to N+1, or for a multi-arm path N to N+arms, so it's the change along the same arm. Directions are reckoned anti-clockwise around from the X axis. .Sp .Vb 7 \& | * dX=2,dY=2 \& dX=\-1,dY=1 * | / \& \e|/ \& \-\-\-\-\-\-+\-\-\-\-* dX=1,dY=0 \& | \& | \& * dX=0,dY=\-1 .Ve .Sp A path which is always goes N,S,E,W such as the \f(CW\*(C`SquareSpiral\*(C'\fR has minimum East dX=1,dY=0 and maximum South dX=0,dY=\-1. .Sp Paths which go diagonally may have different limits. For example the \&\f(CW\*(C`KnightSpiral\*(C'\fR goes in 2x1 steps and so has minimum East-North-East dX=2,dY=1 and maximum East-South-East dX=2,dY=\-1. .Sp If the path has directions approaching 360 degrees then \&\f(CW\*(C`dir_maximum_dxdy()\*(C'\fR is 0,0 which should be taken to mean a full circle as a supremum. For example \f(CW\*(C`MultipleRings\*(C'\fR. .Sp If the path only ever goes East then the maximum is East dX=1,dY=0, and the minimum the same. This isn't particularly interesting, but arises for example in the \f(CW\*(C`Columns\*(C'\fR path height=0. .ie n .IP """$bool = $path\->turn_any_left()""" 4 .el .IP "\f(CW$bool = $path\->turn_any_left()\fR" 4 .IX Item "$bool = $path->turn_any_left()" .PD 0 .ie n .IP """$bool = $path\->turn_any_right()""" 4 .el .IP "\f(CW$bool = $path\->turn_any_right()\fR" 4 .IX Item "$bool = $path->turn_any_right()" .ie n .IP """$bool = $path\->turn_any_straight()""" 4 .el .IP "\f(CW$bool = $path\->turn_any_straight()\fR" 4 .IX Item "$bool = $path->turn_any_straight()" .PD Return true if the path turns left, right, or straight (which includes 180deg reverse) at any integer N. .Sp .Vb 1 \& N+1 left \& \& N\-1 \-\-\-\-\-\-\-\- N \-\-> N+1 straight \& \& N+1 right .Ve .Sp A line from N\-1 to N is a current direction and the turn at N is then whether point N+1 is to the left or right of that line. Directly along the line is straight, and so is anything directly behind as a reverse. This is the turn style of Math::NumSeq::PlanePathTurn. .ie n .IP """$str = $path\->figure()""" 4 .el .IP "\f(CW$str = $path\->figure()\fR" 4 .IX Item "$str = $path->figure()" Return a string name of the figure (shape) intended to be drawn at each \&\f(CW$n\fR position. This is currently either .Sp .Vb 2 \& "square" side 1 centred on $x,$y \& "circle" diameter 1 centred on $x,$y .Ve .Sp Of course this is only a suggestion since PlanePath doesn't draw anything itself. A figure like a diamond for instance can look good too. .SS "Tree Methods" .IX Subsection "Tree Methods" Some paths are structured like a tree where each N has a parent and possibly some children. .PP .Vb 5 \& 123 \& / | \e \& 456 999 458 \& / / \e \& 1000 1001 1005 .Ve .PP The N numbering and any relation to X,Y positions varies among the paths. Some are numbered by rows in breadth-first style and some have children with X,Y positions adjacent to their parent, but that shouldn't be assumed, only that there's a parent-child relation down from some set of root nodes. .ie n .IP """$bool = $path\->is_tree()""" 4 .el .IP "\f(CW$bool = $path\->is_tree()\fR" 4 .IX Item "$bool = $path->is_tree()" Return true if \f(CW$path\fR is a tree. .Sp The various tree methods have empty or \f(CW\*(C`undef\*(C'\fR returns on non-tree paths. Often it's enough to check for that from a desired method rather than a separate \f(CW\*(C`is_tree()\*(C'\fR check. .ie n .IP """@n_children = $path\->tree_n_children($n)""" 4 .el .IP "\f(CW@n_children = $path\->tree_n_children($n)\fR" 4 .IX Item "@n_children = $path->tree_n_children($n)" Return a list of N values which are the child nodes of \f(CW$n\fR, or return an empty list if \f(CW$n\fR has no children. .Sp There could be no children either because \f(CW$path\fR is not a tree or because there's no children at a particular \f(CW$n\fR. .ie n .IP """$num = $path\->tree_n_num_children($n)""" 4 .el .IP "\f(CW$num = $path\->tree_n_num_children($n)\fR" 4 .IX Item "$num = $path->tree_n_num_children($n)" Return the number of children of \f(CW$n\fR, or 0 if \f(CW$n\fR has no children, or \&\f(CW\*(C`undef\*(C'\fR if \f(CW\*(C`$n < n_start()\*(C'\fR (ie. before the start of the path). .Sp If the tree is considered as a directed graph then this is the \*(L"out-degree\*(R" of \f(CW$n\fR. .ie n .IP """$n_parent = $path\->tree_n_parent($n)""" 4 .el .IP "\f(CW$n_parent = $path\->tree_n_parent($n)\fR" 4 .IX Item "$n_parent = $path->tree_n_parent($n)" Return the parent node of \f(CW$n\fR, or \f(CW\*(C`undef\*(C'\fR if it has no parent. .Sp There is no parent at the root node of the tree, or one of multiple roots, or if \f(CW$path\fR is not a tree. .ie n .IP """$n_root = $path\->tree_n_root ($n)""" 4 .el .IP "\f(CW$n_root = $path\->tree_n_root ($n)\fR" 4 .IX Item "$n_root = $path->tree_n_root ($n)" Return the N which is the root node of \f(CW$n\fR. This is the top of the tree as would be found by following \f(CW\*(C`tree_n_parent()\*(C'\fR repeatedly. .Sp The return is \f(CW\*(C`undef\*(C'\fR if there's no \f(CW$n\fR point or if \f(CW$path\fR is not a tree. .ie n .IP """$depth = $path\->tree_n_to_depth($n)""" 4 .el .IP "\f(CW$depth = $path\->tree_n_to_depth($n)\fR" 4 .IX Item "$depth = $path->tree_n_to_depth($n)" Return the depth of node \f(CW$n\fR, or \f(CW\*(C`undef\*(C'\fR if there's no point \f(CW$n\fR. The top of the tree is depth=0, then its children are depth=1, etc. .Sp The depth is a count of how many parent, grandparent, etc, levels are above \&\f(CW$n\fR, ie. until reaching \f(CW\*(C`tree_n_to_parent()\*(C'\fR returning \f(CW\*(C`undef\*(C'\fR. For non-tree paths \f(CW\*(C`tree_n_to_parent()\*(C'\fR is always \f(CW\*(C`undef\*(C'\fR and \&\f(CW\*(C`tree_n_to_depth()\*(C'\fR is always 0. .ie n .IP """$n_lo = $path\->tree_depth_to_n($depth)""" 4 .el .IP "\f(CW$n_lo = $path\->tree_depth_to_n($depth)\fR" 4 .IX Item "$n_lo = $path->tree_depth_to_n($depth)" .PD 0 .ie n .IP """$n_hi = $path\->tree_depth_to_n_end($depth)""" 4 .el .IP "\f(CW$n_hi = $path\->tree_depth_to_n_end($depth)\fR" 4 .IX Item "$n_hi = $path->tree_depth_to_n_end($depth)" .ie n .IP """($n_lo, $n_hi) = $path\->tree_depth_to_n_range ($depth)""" 4 .el .IP "\f(CW($n_lo, $n_hi) = $path\->tree_depth_to_n_range ($depth)\fR" 4 .IX Item "($n_lo, $n_hi) = $path->tree_depth_to_n_range ($depth)" .PD Return the first or last N, or both those N, for tree level \f(CW$depth\fR in the path. If there's no such \f(CW$depth\fR or if \f(CW$path\fR is not a tree then return \&\f(CW\*(C`undef\*(C'\fR, or for \f(CW\*(C`tree_depth_to_n_range()\*(C'\fR return an empty list. .Sp The points \f(CW$n_lo\fR through \f(CW$n_hi\fR might not necessarily all be at \&\f(CW$depth\fR. It's possible for depths to be interleaved or intermixed in the point numbering. But many paths are breadth-wise successive rows and for them \f(CW$n_lo\fR to \f(CW$n_hi\fR inclusive is all \f(CW$depth\fR. .Sp \&\f(CW$n_hi\fR can only exist if the row has a finite number of points. That's true of all current paths, but perhaps allowance ought to be made for \&\f(CW$n_hi\fR as \f(CW\*(C`undef\*(C'\fR or some such if there is no maximum N for some row. .ie n .IP """$num = $path\->tree_depth_to_width ($depth)""" 4 .el .IP "\f(CW$num = $path\->tree_depth_to_width ($depth)\fR" 4 .IX Item "$num = $path->tree_depth_to_width ($depth)" Return the number of points at \f(CW$depth\fR in the tree. If there's no such \&\f(CW$depth\fR or \f(CW$path\fR is not a tree then return \f(CW\*(C`undef\*(C'\fR. .ie n .IP """$height = $path\->tree_n_to_subheight($n)""" 4 .el .IP "\f(CW$height = $path\->tree_n_to_subheight($n)\fR" 4 .IX Item "$height = $path->tree_n_to_subheight($n)" Return the height of the sub-tree starting at \f(CW$n\fR, or \f(CW\*(C`undef\*(C'\fR if infinite. The height of a tree is the longest distance down to a leaf node. For example, .Sp .Vb 9 \& ... N subheight \& \e \-\-\- \-\-\-\-\-\-\-\-\- \& 6 7 8 0 undef \& \e \e / 1 undef \& 3 4 5 2 2 \& \e \e / 3 undef \& 1 2 4 1 \& \e / 5 0 \& 0 ... .Ve .Sp At N=0 and all of the left side the tree continues infinitely so the sub-height there is \f(CW\*(C`undef\*(C'\fR for infinite. For N=2 the sub-height is 2 because the longest path down is 2 levels (to N=7 or N=8). For a leaf node such as N,=5 the sub-height is 0. .SS "Tree Descriptive Methods" .IX Subsection "Tree Descriptive Methods" .ie n .IP """$num = $path\->tree_num_roots()""" 4 .el .IP "\f(CW$num = $path\->tree_num_roots()\fR" 4 .IX Item "$num = $path->tree_num_roots()" Return the number of root nodes in \f(CW$path\fR. If \f(CW$path\fR is not a tree then return 0. Many tree paths have a single root and for them the return is 1. .ie n .IP """@n_list = $path\->tree_root_n_list()""" 4 .el .IP "\f(CW@n_list = $path\->tree_root_n_list()\fR" 4 .IX Item "@n_list = $path->tree_root_n_list()" Return a list of the N values which are the root nodes in \f(CW$path\fR. If \&\f(CW$path\fR is not a tree then this is an empty list. There are \&\f(CW\*(C`tree_num_roots()\*(C'\fR many return values. .ie n .IP """$num = $path\->tree_num_children_minimum()""" 4 .el .IP "\f(CW$num = $path\->tree_num_children_minimum()\fR" 4 .IX Item "$num = $path->tree_num_children_minimum()" .PD 0 .ie n .IP """$num = $path\->tree_num_children_maximum()""" 4 .el .IP "\f(CW$num = $path\->tree_num_children_maximum()\fR" 4 .IX Item "$num = $path->tree_num_children_maximum()" .ie n .IP """@nums = $path\->tree_num_children_list()""" 4 .el .IP "\f(CW@nums = $path\->tree_num_children_list()\fR" 4 .IX Item "@nums = $path->tree_num_children_list()" .PD Return the possible number of children of the nodes of \f(CW$path\fR, either the minimum, the maximum, or a list of all possible numbers of children. .Sp For \f(CW\*(C`tree_num_children_list()\*(C'\fR the list of values is in increasing order, so the first value is \f(CW\*(C`tree_num_children_minimum()\*(C'\fR and the last is \&\f(CW\*(C`tree_num_children_maximum()\*(C'\fR. .ie n .IP """$bool = $path\->tree_any_leaf()""" 4 .el .IP "\f(CW$bool = $path\->tree_any_leaf()\fR" 4 .IX Item "$bool = $path->tree_any_leaf()" Return true if there are any leaf nodes in the tree, meaning any N for which \&\f(CW\*(C`tree_n_num_children()\*(C'\fR is 0. .Sp This is the same as \f(CW\*(C`tree_num_children_minimum()==0\*(C'\fR since if NumChildren=0 occurs then there are leaf nodes. .Sp Some trees may have no leaf nodes, for example in the complete binary tree of \f(CW\*(C`RationalsTree\*(C'\fR every node always has 2 children. .SS "Level Methods" .IX Subsection "Level Methods" .ie n .IP """level = $path\->n_to_level($n)""" 4 .el .IP "\f(CWlevel = $path\->n_to_level($n)\fR" 4 .IX Item "level = $path->n_to_level($n)" Return the replication level containing \f(CW$n\fR. The first level is 0. .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 the range of N values, inclusive, which comprise a self-similar replication level in \f(CW$path\fR. If \f(CW$path\fR has no notion of such levels then return an empty list. .Sp .Vb 2 \& my ($n_lo, $n_hi) = $path\->level_to_n_range(6) \& or print "no levels in this path"; .Ve .Sp For example the \f(CW\*(C`DragonCurve\*(C'\fR has levels running \f(CW0\fR to \f(CW\*(C`2**$level\*(C'\fR, or the \f(CW\*(C`HilbertCurve\*(C'\fR is \f(CW0\fR to \f(CW\*(C`4**$level \- 1\*(C'\fR. Most levels are powers like this. A power \f(CW\*(C`2**$level\*(C'\fR is a \*(L"vertex\*(R" style whereas \f(CW\*(C`2**$level \- 1\*(C'\fR is a \*(L"centre\*(R" style. The difference is generally whether the X,Y points represent vertices of the object's segments as opposed to centres or midpoints. .SS "Parameter Methods" .IX Subsection "Parameter Methods" .ie n .IP """$aref = Math::PlanePath::Foo\->parameter_info_array()""" 4 .el .IP "\f(CW$aref = Math::PlanePath::Foo\->parameter_info_array()\fR" 4 .IX Item "$aref = Math::PlanePath::Foo->parameter_info_array()" .PD 0 .ie n .IP """@list = Math::PlanePath::Foo\->parameter_info_list()""" 4 .el .IP "\f(CW@list = Math::PlanePath::Foo\->parameter_info_list()\fR" 4 .IX Item "@list = Math::PlanePath::Foo->parameter_info_list()" .PD Return an arrayref of list describing the parameters taken by a given class. This meant to help making widgets etc for user interaction in a \s-1GUI.\s0 Each element is a hashref .Sp .Vb 11 \& { \& name => parameter key arg for new() \& share_key => string, or undef \& description => human readable string \& type => string "integer","boolean","enum" etc \& default => value \& minimum => number, or undef \& maximum => number, or undef \& width => integer, suggested display size \& choices => for enum, an arrayref \& } .Ve .Sp \&\f(CW\*(C`type\*(C'\fR is a string, one of .Sp .Vb 5 \& "integer" \& "enum" \& "boolean" \& "string" \& "filename" .Ve .Sp \&\*(L"filename\*(R" is separate from \*(L"string\*(R" since it might require subtly different handling to reach Perl as a byte string, whereas a \*(L"string\*(R" type might in principle take Perl wide chars. .Sp For \*(L"enum\*(R" the \f(CW\*(C`choices\*(C'\fR field is the possible values, such as .Sp .Vb 4 \& { name => "flavour", \& type => "enum", \& choices => ["strawberry","chocolate"], \& } .Ve .Sp \&\f(CW\*(C`minimum\*(C'\fR and/or \f(CW\*(C`maximum\*(C'\fR are omitted if there's no hard limit on the parameter. .Sp \&\f(CW\*(C`share_key\*(C'\fR is designed to indicate when parameters from different \&\f(CW\*(C`PlanePath\*(C'\fR classes can done by a single control widget in a \s-1GUI\s0 etc. Normally the \f(CW\*(C`name\*(C'\fR is enough, but when the same name has slightly different meanings in different classes a \f(CW\*(C`share_key\*(C'\fR allows the same meanings to be matched up. .ie n .IP """$hashref = Math::PlanePath::Foo\->parameter_info_hash()""" 4 .el .IP "\f(CW$hashref = Math::PlanePath::Foo\->parameter_info_hash()\fR" 4 .IX Item "$hashref = Math::PlanePath::Foo->parameter_info_hash()" Return a hashref mapping parameter names \f(CW\*(C`$info\->{\*(Aqname\*(Aq}\*(C'\fR to their \&\f(CW$info\fR records. .Sp .Vb 5 \& { wider => { name => "wider", \& type => "integer", \& ... \& }, \& } .Ve .SH "GENERAL CHARACTERISTICS" .IX Header "GENERAL CHARACTERISTICS" The classes are mostly based on integer \f(CW$n\fR positions and those designed for a square grid turn an integer \f(CW$n\fR into integer \f(CW\*(C`$x,$y\*(C'\fR. Usually they give in-between positions for fractional \f(CW$n\fR too. Classes not on a square grid but instead giving fractional X,Y such as \f(CW\*(C`SacksSpiral\*(C'\fR and \&\f(CW\*(C`VogelFloret\*(C'\fR are designed for a unit circle at each \f(CW$n\fR but they too can give in-between positions on request. .PP All X,Y positions are calculated by separate \f(CW\*(C`n_to_xy()\*(C'\fR calls. To follow a path use successive \f(CW$n\fR values starting from \f(CW\*(C`$path\->n_start()\*(C'\fR. .PP .Vb 4 \& foreach my $n ($path\->n_start .. 100) { \& my ($x,$y) = $path\->n_to_xy($n); \& print "$n $x,$y\en"; \& } .Ve .PP The separate \f(CW\*(C`n_to_xy()\*(C'\fR calls were motivated by plotting just some N points of a path, such as just the primes or the perfect squares. Successive positions in paths could perhaps be done more efficiently in an iterator style. Paths with a quadratic \*(L"step\*(R" are not much worse than a \&\f(CW\*(C`sqrt()\*(C'\fR to break N into a segment and offset, but the self-similar paths which chop N into digits of some radix could increment instead of recalculate. .PP If interested only in a particular rectangle or similar region then iterating has the disadvantage that it may stray outside the target region for a long time, making an iterator much less useful than it seems. For wild paths it can be better to apply \f(CW\*(C`xy_to_n()\*(C'\fR by rows or similar across the desired region. .PP Math::NumSeq::PlanePathCoord etc offer the PlanePath coordinates, directions, turns, etc as sequences. The iterator forms there simply make repeated calls to \f(CW\*(C`n_to_xy()\*(C'\fR etc. .SS "Scaling and Orientation" .IX Subsection "Scaling and Orientation" The paths generally make a first move to the right and go anti-clockwise around from the X axis, unless there's some more natural orientation. Anti-clockwise is the usual direction for mathematical spirals. .PP There's no parameters for scaling, offset or reflection as those things are thought better left to a general coordinate transformer, for example to expand or invert for display. Some easy transformations can be had just from the X,Y with .PP .Vb 2 \& \-X,Y flip horizontally (mirror image) \& X,\-Y flip vertically (across the X axis) \& \& \-Y,X rotate +90 degrees (anti\-clockwise) \& Y,\-X rotate \-90 degrees (clockwise) \& \-X,\-Y rotate 180 degrees .Ve .PP Flip vertically makes spirals go clockwise instead of anti-clockwise, or a flip horizontally the same but starting on the left at the negative X axis. See \*(L"Triangular Lattice\*(R" below for 60 degree rotations of the triangular grid paths too. .PP The Rows and Columns paths are exceptions to the rule of not having rotated versions of paths. They began as ways to pass in width and height as generic parameters and let the path use the one or the other. .PP For scaling and shifting see for example Transform::Canvas, and to rotate as well see Geometry::AffineTransform. .SS "Loop Step" .IX Subsection "Loop Step" The paths can be characterized by how much longer each loop or repetition is than the preceding one. For example each cycle around the \f(CW\*(C`SquareSpiral\*(C'\fR is 8 more N points than the preceding. .PP .Vb 10 \& Step Path \& \-\-\-\- \-\-\-\- \& 0 Rows, Columns (fixed widths) \& 1 Diagonals \& 2/2 DiagonalsOctant (2 rows for +2) \& 2 SacksSpiral, Corner, CornerAlternating, \& PyramidSides, PyramidRows (default) \& 4 DiamondSpiral, AztecDiamondRings, Staircase \& 4/2 CellularRule54, CellularRule57, \& DiagonalsAlternating (2 rows for +4) \& 5 PentSpiral, PentSpiralSkewed \& 5.65 PixelRings (average about 4*sqrt(2)) \& 6 HexSpiral, HexSpiralSkewed, MPeaks, \& MultipleRings (default) \& 6/2 CellularRule190 (2 rows for +6) \& 6.28 ArchimedeanChords (approaching 2*pi), \& FilledRings (average 2*pi) \& 7 HeptSpiralSkewed \& 8 SquareSpiral, PyramidSpiral \& 16/2 StaircaseAlternating (up and back for +16) \& 9 TriangleSpiral, TriangleSpiralSkewed \& 12 AnvilSpiral \& 16 OctagramSpiral, ToothpickSpiral \& 19.74 TheodorusSpiral (approaching 2*pi^2) \& 32/4 KnightSpiral (4 loops 2\-wide for +32) \& 64 DiamondArms (each arm) \& 72 GreekKeySpiral \& 128 SquareArms (each arm) \& 128/4 CretanLabyrinth (4 loops for +128) \& 216 HexArms (each arm) \& \& totient CoprimeColumns, DiagonalRationals \& numdivisors DivisibleColumns \& various CellularRule \& \& parameter MultipleRings, PyramidRows .Ve .PP The step determines which quadratic number sequences make straight lines. For example the gap between successive perfect squares increases by 2 each time (4 to 9 is +5, 9 to 16 is +7, 16 to 25 is +9, etc), so the perfect squares make a straight line in the paths of step 2. .PP In general straight lines on stepped paths are quadratics .PP .Vb 1 \& N = a*k^2 + b*k + c where a=step/2 .Ve .PP The polygonal numbers are like this, with the (step+2)\-gonal numbers making a straight line on a \*(L"step\*(R" path. For example the 7\-gonals (heptagonals) are 5/2*k^2\-3/2*k and make a straight line on the step=5 \f(CW\*(C`PentSpiral\*(C'\fR. Or the 8\-gonal octagonal numbers 6/2*k^2\-4/2*k on the step=6 \f(CW\*(C`HexSpiral\*(C'\fR. .PP There are various interesting properties of primes in quadratic progressions. Some quadratics seem to have more primes than others. For example see \*(L"Lucky Numbers of Euler\*(R" in Math::PlanePath::PyramidSides. Many quadratics have no primes at all, or none above a certain point, either trivially if always a multiple of 2 etc, or by a more sophisticated reasoning. See \*(L"Step 3 Pentagonals\*(R" in Math::PlanePath::PyramidRows for a factorization on the roots making a no-primes gap. .PP A 4*step path splits a straight line in two, so for example the perfect squares are a straight line on the step=2 \*(L"Corner\*(R" path, and then on the step=8 \f(CW\*(C`SquareSpiral\*(C'\fR they instead fall on two lines (lower left and upper right). In the bigger step there's one line of the even squares (2k)^2 == 4*k^2 and another of the odd squares (2k+1)^2. The gap between successive even squares increases by 8 each time and likewise between odd squares. .SS "Self-Similar Powers" .IX Subsection "Self-Similar Powers" The self-similar patterns such as \f(CW\*(C`PeanoCurve\*(C'\fR generally have a base pattern which repeats at powers N=base^level or squares N=(base*base)^level. Or some multiple or relationship to such a power for things like \&\f(CW\*(C`KochPeaks\*(C'\fR and \f(CW\*(C`GosperIslands\*(C'\fR. .PP .Vb 10 \& Base Path \& \-\-\-\- \-\-\-\- \& 2 HilbertCurve, HilbertSides, HilbertSpiral, \& ZOrderCurve (default), GrayCode (default), \& BetaOmega, AR2W2Curve, HIndexing, \& ImaginaryBase (default), ImaginaryHalf (default), \& SierpinskiCurve, SierpinskiCurveStair, \& CubicBase (default) CornerReplicate, \& ComplexMinus (default), ComplexPlus (default), \& ComplexRevolving, DragonCurve, DragonRounded, \& DragonMidpoint, AlternatePaper, AlternatePaperMidpoint, \& CCurve, DigitGroups (default), PowerArray (default) \& 3 PeanoCurve (default), PeanoDiagonals (default), \& WunderlichSerpentine (default),WunderlichMeander, \& KochelCurve, GosperIslands, GosperSide \& SierpinskiTriangle, SierpinskiArrowhead, \& SierpinskiArrowheadCentres, \& TerdragonCurve, TerdragonRounded, TerdragonMidpoint, \& AlternateTerdragon, \& UlamWarburton, UlamWarburtonQuarter (each level) \& 4 KochCurve, KochPeaks, KochSnowflakes, KochSquareflakes, \& LTiling, \& 5 QuintetCurve, QuintetCentres, QuintetReplicate, \& DekkingCurve, DekkingCentres, CincoCurve, \& R5DragonCurve, R5DragonMidpoint \& 7 Flowsnake, FlowsnakeCentres, GosperReplicate \& 8 QuadricCurve, QuadricIslands \& 9 SquareReplicate \& Fibonacci FibonacciWordFractal, WythoffArray \& parameter PeanoCurve, PeanoDiagonals, WunderlichSerpentine, \& ZOrderCurve, GrayCode, ImaginaryBase, ImaginaryHalf, \& CubicBase, ComplexPlus, ComplexMinus, DigitGroups, \& PowerArray .Ve .PP Many number sequences plotted on these self-similar paths tend to be fairly random, or merely show the tiling or path layout rather than much about the number sequence. Sequences related to the base can make holes or patterns picking out parts of the path. For example numbers without a particular digit (or digits) in the relevant base show up as holes. See for example \&\*(L"Power of 2 Values\*(R" in Math::PlanePath::ZOrderCurve. .SS "Triangular Lattice" .IX Subsection "Triangular Lattice" Some paths are on triangular or \*(L"A2\*(R" lattice points like .PP .Vb 11 \& *\-\-\-*\-\-\-*\-\-\-*\-\-\-*\-\-\-* \& / \e / \e / \e / \e / \e / \& *\-\-\-*\-\-\-*\-\-\-*\-\-\-*\-\-\-* \& \e / \e / \e / \e / \e / \e \& *\-\-\-*\-\-\-*\-\-\-*\-\-\-*\-\-\-* \& / \e / \e / \e / \e / \e / \& *\-\-\-*\-\-\-*\-\-\-*\-\-\-*\-\-\-* \& \e / \e / \e / \e / \e / \e \& *\-\-\-*\-\-\-*\-\-\-*\-\-\-*\-\-\-* \& / \e / \e / \e / \e / \e / \& *\-\-\-*\-\-\-*\-\-\-*\-\-\-*\-\-\-* .Ve .PP This is done in integer X,Y on a square grid by using every second square and offsetting alternate rows. This means sum X+Y even, ie. X,Y either both even or both odd, not of opposite parity. .PP .Vb 6 \& . * . * . * . * . * . * \& * . * . * . * . * . * . \& . * . * . * . * . * . * \& * . * . * . * . * . * . \& . * . * . * . * . * . * \& * . * . * . * . * . * . .Ve .PP The X axis the and diagonals X=Y and X=\-Y divide the plane into six equal parts in this grid. .PP .Vb 8 \& X=\-Y X=Y \& \e / \& \e / \& \e / \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- X=0 \& / \e \& / \e \& / \e .Ve .PP The diagonal X=3*Y is the middle of the first sixth, representing a twelfth of the plane. .PP The resulting triangles are flatter than they should be. The triangle base is width=2 and top is height=1, whereas it would be height=\fBsqrt\fR\|(3) for an equilateral triangle. That \fBsqrt\fR\|(3) factor can be applied if desired, .PP .Vb 1 \& X, Y*sqrt(3) side length 2 \& \& X/2, Y*sqrt(3)/2 side length 1 .Ve .PP Integer Y values have the advantage of fitting pixels on the usual kind of raster computer screen, and not losing precision in floating point results. .PP If doing a general-purpose coordinate rotation then be sure to apply the \&\fBsqrt\fR\|(3) scale factor before rotating or the result will be skewed. 60 degree rotations can be made within the integer X,Y coordinates directly as follows, all giving integer X,Y results. .PP .Vb 5 \& ( X\-3Y)/2, ( X+Y)/2 rotate +60 (anti\-clockwise) \& ( X+3Y)/2, (\-X+Y)/2 rotate \-60 (clockwise) \& (\-X\-3Y)/2, ( X\-Y)/2 rotate +120 \& (\-X+3Y)/2, (\-X\-Y)/2 rotate \-120 \& \-X,\-Y rotate 180 \& \& (X+3Y)/2, (X\-Y)/2 mirror across the X=3*Y twelfth (30deg) .Ve .PP The \fBsqrt\fR\|(3) factor can be worked into a hypotenuse radial distance calculation as follows if comparing distances from the origin. .PP .Vb 1 \& hypot = sqrt(X*X + 3*Y*Y) .Ve .PP See for instance \f(CW\*(C`TriangularHypot\*(C'\fR which is triangular points ordered by this radial distance. .SH "FORMULAS" .IX Header "FORMULAS" The formulas section in the \s-1POD\s0 of each class describes some of the calculations. This might be of interest even if the code is not. .SS "Triangular Calculations" .IX Subsection "Triangular Calculations" For a triangular lattice, the rotation formulas above allow calculations to be done in the rectangular X,Y coordinates which are the inputs and outputs of the PlanePath functions. Another way is to number vertically on a 60 degree angle with coordinates i,j, .PP .Vb 5 \& ... \& * * * 2 \& * * * 1 \& * * * j=0 \& i=0 1 2 .Ve .PP These coordinates are sometimes used for hexagonal grids in board games etc. Using this internally can simplify rotations a little, .PP .Vb 5 \& \-j, i+j rotate +60 (anti\-clockwise) \& i+j, \-i rotate \-60 (clockwise) \& \-i\-j, i rotate +120 \& j, \-i\-j rotate \-120 \& \-i, \-j rotate 180 .Ve .PP Conversions between i,j and the rectangular X,Y are .PP .Vb 2 \& X = 2*i + j i = (X\-Y)/2 \& Y = j j = Y .Ve .PP A third coordinate k at a +120 degrees angle can be used too, .PP .Vb 5 \& k=0 k=1 k=2 \& * * * \& * * * \& * * * \& 0 1 2 .Ve .PP This is redundant in that it doesn't number anything i,j alone can't already, but it has the advantage of turning rotations into just sign changes and swaps, .PP .Vb 5 \& \-k, i, j rotate +60 \& j, k, \-i rotate \-60 \& \-j, \-k, i rotate +120 \& k, \-i, \-j rotate \-120 \& \-i, \-j, \-k rotate 180 .Ve .PP The conversions between i,j,k and the rectangular X,Y are like the i,j above but with k worked in too. .PP .Vb 3 \& X = 2i + j \- k i = (X\-Y)/2 i = (X+Y)/2 \& Y = j + k j = Y or j = 0 \& k = 0 k = Y .Ve .SS "N to dX,dY \*(-- Fractional" .IX Subsection "N to dX,dY Fractional" \&\f(CW\*(C`n_to_dxdy()\*(C'\fR is the change from N to N+1, and is designed both for integer N and fractional N. For fractional N it can be convenient to calculate a dX,dY at floor(N) and at floor(N)+1 and then combine the two in proportion to frac(N). .PP .Vb 10 \& int+2 \& | \& | \& N+1 \e \& /| | \& / | | \& / | | frac \& / | | \& / | | \& / | / \& int\-\-\-\-\-N\-\-\-\-\-\-int+1 \& this_dX dX,dY next_dX \& this_dY next_dY \& \& |\-\-\-\-\-\-\-|\-\-\-\-\-\-| \& frac 1\-frac \& \& \& int = int(N) \& frac = N \- int 0 <= frac < 1 \& \& this_dX,this_dY at int \& next_dX,next_dY at int+1 \& \& at fractional N \& dX = this_dX * (1\-frac) + next_dX * frac \& dY = this_dY * (1\-frac) + next_dY * frac .Ve .PP This is combination of this_dX,this_dY and next_dX,next_dY in proportion to the distances from positions N to int+1 and from int+1 to N+1. .PP The formulas can be rearranged to .PP .Vb 2 \& dX = this_dX + frac*(next_dX \- this_dX) \& dY = this_dY + frac*(next_dY \- this_dY) .Ve .PP which is like dX,dY at the integer position plus fractional part of a turn or change to the next dX,dY. .SS "N to dX,dY \*(-- Self-Similar" .IX Subsection "N to dX,dY Self-Similar" For most of the self-similar paths such as \f(CW\*(C`HilbertCurve\*(C'\fR, the change dX,dY is determined by following the state table transitions down through either all digits of N, or to the last non\-9 digit, ie. drop any low digits equal to radix\-1. .PP Generally paths which are the edges of some tiling use all digits, and those which are the centres of a tiling stop at the lowest non\-9. This can be seen for example in the \f(CW\*(C`DekkingCurve\*(C'\fR using all digits, whereas its \&\f(CW\*(C`DekkingCentres\*(C'\fR variant stops at the lowest non\-24. .PP Perhaps this all-digits vs low\-non\-9 would even characterize path style as edges or centres of a tiling, when a path is specified in some way that a tiling is not quite obvious. .SH "SUBCLASSING" .IX Header "SUBCLASSING" The mandatory methods for a PlanePath subclass are .PP .Vb 4 \& n_to_xy() \& xy_to_n() \& xy_to_n_list() if multiple N\*(Aqs map to an X,Y \& rect_to_n_range() .Ve .PP It sometimes happens that one of \f(CW\*(C`n_to_xy()\*(C'\fR or \f(CW\*(C`xy_to_n()\*(C'\fR is easier than the other but both should be implemented. .PP \&\f(CW\*(C`n_to_xy()\*(C'\fR should do something sensible on fractional N. The suggestion is to make it an X,Y proportionally between integer N positions. It could be along a straight line or an arc as best suits the path. A straight line can be done simply by two calculations of the surrounding integer points, until it's clear how to work the fraction into the code directly. .PP \&\f(CW\*(C`xy_to_n_list()\*(C'\fR has a base implementation calling plain \f(CW\*(C`xy_to_n()\*(C'\fR to give a single N at X,Y. If a path has multiple Ns at an X,Y (eg. \f(CW\*(C`DragonCurve\*(C'\fR) then it must implement \f(CW\*(C`xy_to_n_list()\*(C'\fR to return all those Ns, and must also implement a plain \f(CW\*(C`xy_to_n()\*(C'\fR returning the first of them. .PP \&\f(CW\*(C`rect_to_n_range()\*(C'\fR can initially be any convenient over-estimate. It should give N big enough that from there onwards all points are sure to be beyond the given X,Y rectangle. .PP The following descriptive methods have base implementations .PP .Vb 7 \& n_start() 1 \& class_x_negative() \e 1, so whole plane \& class_y_negative() / \& x_negative() calls class_x_negative() \& y_negative() calls class_x_negative() \& x_negative_at_n() undef \e as for no negatives \& y_negative_at_n() undef / .Ve .PP The base \f(CW\*(C`n_start()\*(C'\fR starts at N=1. Paths which treat N as digits of some radix or where there's self-similar replication are often best started from N=0 instead since doing so puts nice powers\-of\-2 etc on the axes or diagonals. .PP .Vb 1 \& use constant n_start => 0; # digit or replication style .Ve .PP Paths which use only parts of the plane should define \f(CW\*(C`class_x_negative()\*(C'\fR and/or \f(CW\*(C`class_y_negative()\*(C'\fR to false. For example if only the first quadrant X>=0,Y>=0 then .PP .Vb 2 \& use constant class_x_negative => 0; \& use constant class_y_negative => 0; .Ve .PP If negativeness varies with path parameters then \f(CW\*(C`x_negative()\*(C'\fR and/or \&\f(CW\*(C`y_negative()\*(C'\fR follow those parameters and the \f(CW\*(C`class_()\*(C'\fR forms are whether any set of parameters ever gives negative. .PP The following methods have base implementations calling \f(CW\*(C`n_to_xy()\*(C'\fR. A subclass can implement them directly if they can be done more efficiently. .PP .Vb 3 \& n_to_dxdy() calls n_to_xy() twice \& n_to_rsquared() calls n_to_xy() \& n_to_radius() sqrt of n_to_rsquared() .Ve .PP \&\f(CW\*(C`SacksSpiral\*(C'\fR is an example of an easy \f(CW\*(C`n_to_rsquared()\*(C'\fR. \&\f(CW\*(C`TheodorusSpiral\*(C'\fR is only slightly trickier. Unless a path has some sort of easy X^2+Y^2 then it might as well let the base implementation call \&\f(CW\*(C`n_to_xy()\*(C'\fR. .PP The way \f(CW\*(C`n_to_dxdy()\*(C'\fR supports fractional N can be a little tricky. One way is to calculate dX,dY on the integer N below and above and combine as described in \*(L"N to dX,dY \*(-- Fractional\*(R". For some paths the calculation of turn or direction at ceil(N) can be worked into a calculation of the direction at floor(N) so not much more work. .PP The following methods have base implementations calling \f(CW\*(C`xy_to_n()\*(C'\fR. A subclass might implement them directly if it can be done more efficiently. .PP .Vb 5 \& xy_is_visited() defined(xy_to_n($x,$y)) \& xyxy_to_n() \e \& xyxy_to_n_either() | calling xy_to_n_list() \& xyxy_to_n_list() | \& xyxy_to_n_list_either() / .Ve .PP Paths such as \f(CW\*(C`SquareSpiral\*(C'\fR which fill the plane have \f(CW\*(C`xy_is_visited()\*(C'\fR always true, so for them .PP .Vb 1 \& use constant xy_is_visited => 1; .Ve .PP For a tree path the following methods are mandatory .PP .Vb 6 \& tree_n_parent() \& tree_n_children() \& tree_n_to_depth() \& tree_depth_to_n() \& tree_num_children_list() \& tree_n_to_subheight() .Ve .PP The other tree methods have base implementations, .ie n .IP """is_tree()""" 4 .el .IP "\f(CWis_tree()\fR" 4 .IX Item "is_tree()" Checks for \f(CW\*(C`n_start()\*(C'\fR having non-zero \f(CW\*(C`tree_n_to_num_children()\*(C'\fR. Usually this suffices, expecting \f(CW\*(C`n_start()\*(C'\fR to be a root node and to have some children. .ie n .IP """tree_n_num_children()""" 4 .el .IP "\f(CWtree_n_num_children()\fR" 4 .IX Item "tree_n_num_children()" Calls \f(CW\*(C`tree_n_children()\*(C'\fR and counts the number of return values. Many trees can count the children with less work than calculating outright, for example \f(CW\*(C`RationalsTree\*(C'\fR is simply always 2 for N>=Nstart. .ie n .IP """tree_depth_to_n_end()""" 4 .el .IP "\f(CWtree_depth_to_n_end()\fR" 4 .IX Item "tree_depth_to_n_end()" Calls \f(CW\*(C`tree_depth_to_n($depth+1)\-1\*(C'\fR. This assumes that the depth level ends where the next begins. This is true for the various breadth-wise tree traversals, but anything interleaved etc will need its own implementation. .ie n .IP """tree_depth_to_n_range()""" 4 .el .IP "\f(CWtree_depth_to_n_range()\fR" 4 .IX Item "tree_depth_to_n_range()" Calls \f(CW\*(C`tree_depth_to_n()\*(C'\fR and \f(CW\*(C`tree_depth_to_n_end()\*(C'\fR. For some paths the row start and end, or start and width, might be calculated together more efficiently. .ie n .IP """tree_depth_to_width()""" 4 .el .IP "\f(CWtree_depth_to_width()\fR" 4 .IX Item "tree_depth_to_width()" Returns \f(CW\*(C`tree_depth_to_n_end() \- tree_depth_to_n() + 1\*(C'\fR. This suits breadth-wise style paths where all points at \f(CW$depth\fR are in a contiguous block. Any path not like that will need its own \f(CW\*(C`tree_depth_to_width()\*(C'\fR. .ie n .IP """tree_num_children_minimum()"", ""tree_num_children_maximum()""" 4 .el .IP "\f(CWtree_num_children_minimum()\fR, \f(CWtree_num_children_maximum()\fR" 4 .IX Item "tree_num_children_minimum(), tree_num_children_maximum()" Return the first and last values of \f(CW\*(C`tree_num_children_list()\*(C'\fR as the minimum and maximum. .ie n .IP """tree_any_leaf()""" 4 .el .IP "\f(CWtree_any_leaf()\fR" 4 .IX Item "tree_any_leaf()" Calls \f(CW\*(C`tree_num_children_minimum()\*(C'\fR. If the minimum \f(CW\*(C`num_children\*(C'\fR is 0 then there's leaf nodes. .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath::SquareSpiral, Math::PlanePath::PyramidSpiral, Math::PlanePath::TriangleSpiral, Math::PlanePath::TriangleSpiralSkewed, Math::PlanePath::DiamondSpiral, Math::PlanePath::PentSpiral, Math::PlanePath::PentSpiralSkewed, Math::PlanePath::HexSpiral, Math::PlanePath::HexSpiralSkewed, Math::PlanePath::HeptSpiralSkewed, Math::PlanePath::AnvilSpiral, Math::PlanePath::OctagramSpiral, Math::PlanePath::KnightSpiral, Math::PlanePath::CretanLabyrinth .PP Math::PlanePath::HexArms, Math::PlanePath::SquareArms, Math::PlanePath::DiamondArms, Math::PlanePath::AztecDiamondRings, Math::PlanePath::GreekKeySpiral, Math::PlanePath::MPeaks .PP Math::PlanePath::SacksSpiral, Math::PlanePath::VogelFloret, Math::PlanePath::TheodorusSpiral, Math::PlanePath::ArchimedeanChords, Math::PlanePath::MultipleRings, Math::PlanePath::PixelRings, Math::PlanePath::FilledRings, Math::PlanePath::Hypot, Math::PlanePath::HypotOctant, Math::PlanePath::TriangularHypot, Math::PlanePath::PythagoreanTree .PP Math::PlanePath::PeanoCurve, Math::PlanePath::PeanoDiagonals, Math::PlanePath::WunderlichSerpentine, Math::PlanePath::WunderlichMeander, Math::PlanePath::HilbertCurve, Math::PlanePath::HilbertSides, Math::PlanePath::HilbertSpiral, Math::PlanePath::ZOrderCurve, Math::PlanePath::GrayCode, Math::PlanePath::AR2W2Curve, Math::PlanePath::BetaOmega, Math::PlanePath::KochelCurve, Math::PlanePath::DekkingCurve, Math::PlanePath::DekkingCentres, Math::PlanePath::CincoCurve .PP Math::PlanePath::ImaginaryBase, Math::PlanePath::ImaginaryHalf, Math::PlanePath::CubicBase, Math::PlanePath::SquareReplicate, Math::PlanePath::CornerReplicate, Math::PlanePath::LTiling, Math::PlanePath::DigitGroups, Math::PlanePath::FibonacciWordFractal .PP Math::PlanePath::Flowsnake, Math::PlanePath::FlowsnakeCentres, Math::PlanePath::GosperReplicate, Math::PlanePath::GosperIslands, Math::PlanePath::GosperSide .PP Math::PlanePath::QuintetCurve, Math::PlanePath::QuintetCentres, Math::PlanePath::QuintetReplicate .PP Math::PlanePath::KochCurve, Math::PlanePath::KochPeaks, Math::PlanePath::KochSnowflakes, Math::PlanePath::KochSquareflakes .PP Math::PlanePath::QuadricCurve, Math::PlanePath::QuadricIslands .PP Math::PlanePath::SierpinskiCurve, Math::PlanePath::SierpinskiCurveStair, Math::PlanePath::HIndexing .PP Math::PlanePath::SierpinskiTriangle, Math::PlanePath::SierpinskiArrowhead, Math::PlanePath::SierpinskiArrowheadCentres .PP Math::PlanePath::DragonCurve, Math::PlanePath::DragonRounded, Math::PlanePath::DragonMidpoint, Math::PlanePath::AlternatePaper, Math::PlanePath::AlternatePaperMidpoint, Math::PlanePath::TerdragonCurve, Math::PlanePath::TerdragonRounded, Math::PlanePath::TerdragonMidpoint, Math::PlanePath::AlternateTerdragon, Math::PlanePath::R5DragonCurve, Math::PlanePath::R5DragonMidpoint, Math::PlanePath::CCurve .PP Math::PlanePath::ComplexPlus, Math::PlanePath::ComplexMinus, Math::PlanePath::ComplexRevolving .PP Math::PlanePath::Rows, Math::PlanePath::Columns, Math::PlanePath::Diagonals, Math::PlanePath::DiagonalsAlternating, Math::PlanePath::DiagonalsOctant, Math::PlanePath::Staircase, Math::PlanePath::StaircaseAlternating, Math::PlanePath::Corner Math::PlanePath::CornerAlternating .PP Math::PlanePath::PyramidRows, Math::PlanePath::PyramidSides, Math::PlanePath::CellularRule, Math::PlanePath::CellularRule54, Math::PlanePath::CellularRule57, Math::PlanePath::CellularRule190, Math::PlanePath::UlamWarburton, Math::PlanePath::UlamWarburtonQuarter .PP Math::PlanePath::DiagonalRationals, Math::PlanePath::FactorRationals, Math::PlanePath::GcdRationals, Math::PlanePath::RationalsTree, Math::PlanePath::FractionsTree, Math::PlanePath::ChanTree, Math::PlanePath::CfracDigits, Math::PlanePath::CoprimeColumns, Math::PlanePath::DivisibleColumns, Math::PlanePath::WythoffArray, Math::PlanePath::WythoffPreliminaryTriangle, Math::PlanePath::PowerArray, Math::PlanePath::File .PP Math::PlanePath::LCornerTree, Math::PlanePath::LCornerReplicate, Math::PlanePath::ToothpickTree, Math::PlanePath::ToothpickReplicate, Math::PlanePath::ToothpickUpist, Math::PlanePath::ToothpickSpiral, Math::PlanePath::OneOfEight, Math::PlanePath::HTree .PP Math::NumSeq::PlanePathCoord, Math::NumSeq::PlanePathDelta, Math::NumSeq::PlanePathTurn, Math::NumSeq::PlanePathN .PP math-image, displaying various sequences on these paths. .PP \&\fIexamples/numbers.pl\fR, to print all the paths. .SS "Other Ways To Do It" .IX Subsection "Other Ways To Do It" Math::Fractal::Curve, Math::Curve::Hilbert, Algorithm::SpatialIndex::Strategy::QuadTree .PP PerlMagick (module Image::Magick) demo scripts \fIlsys.pl\fR and \fItree.pl\fR .SH "HOME PAGE" .IX Header "HOME PAGE" .PP .SH "LICENSE" .IX Header "LICENSE" Copyright 2010, 2011, 2012, 2013, 2014 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 .