.\" 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::NumSeq::PlanePathCoord 3pm" .TH Math::NumSeq::PlanePathCoord 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::NumSeq::PlanePathCoord \-\- sequence of coordinate values from a PlanePath module .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& use Math::NumSeq::PlanePathCoord; \& my $seq = Math::NumSeq::PlanePathCoord\->new \& (planepath => \*(AqSquareSpiral\*(Aq, \& coordinate_type => \*(AqX\*(Aq); \& my ($i, $value) = $seq\->next; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a tie-in to make a \f(CW\*(C`NumSeq\*(C'\fR sequence giving coordinate values from a \f(CW\*(C`Math::PlanePath\*(C'\fR. The NumSeq \*(L"i\*(R" index is the PlanePath \*(L"N\*(R" value. .PP The \f(CW\*(C`coordinate_type\*(C'\fR choices are as follows. Generally they have some sort of geometric interpretation or are related to fractions X/Y. .PP .Vb 10 \& "X" X coordinate \& "Y" Y coordinate \& "Min" min(X,Y) \& "Max" max(X,Y) \& "MinAbs" min(abs(X),abs(Y)) \& "MaxAbs" max(abs(X),abs(Y)) \& "Sum" X+Y sum \& "SumAbs" abs(X)+abs(Y) sum \& "Product" X*Y product \& "DiffXY" X\-Y difference \& "DiffYX" Y\-X difference (negative of DiffXY) \& "AbsDiff" abs(X\-Y) difference \& "Radius" sqrt(X^2+Y^2) radial distance \& "RSquared" X^2+Y^2 radius squared (norm) \& "TRadius" sqrt(X^2+3*Y^2) triangular radius \& "TRSquared" X^2+3*Y^2 triangular radius squared (norm) \& "IntXY" int(X/Y) division rounded towards zero \& "FracXY" frac(X/Y) division rounded towards zero \& "BitAnd" X bitand Y \& "BitOr" X bitor Y \& "BitXor" X bitxor Y \& "GCD" greatest common divisor X,Y \& "Depth" tree_n_to_depth() \& "SubHeight" tree_n_to_subheight() \& "NumChildren" tree_n_num_children() \& "NumSiblings" not including self \& "RootN" the N which is the tree root \& "IsLeaf" 0 or 1 whether a leaf node (no children) \& "IsNonLeaf" 0 or 1 whether a non\-leaf node (has children) \& also called an "internal" node .Ve .SS "Min and Max" .IX Subsection "Min and Max" \&\*(L"Min\*(R" and \*(L"Max\*(R" are the minimum or maximum of X and Y. The geometric interpretation of \*(L"Min\*(R" is to select X at any point above the X=Y diagonal or Y for any point below. Conversely \*(L"Max\*(R" is Y above and X below. On the X=Y diagonal itself X=Y=Min=Max. .PP .Vb 7 \& Max=Y / X=Y diagonal \& Min=X | / \& |/ \& \-\-\-o\-\-\-\- \& /| \& / | Max=X \& / Min=Y .Ve .PP Min and Max can also be interpreted as counting which gnomon shaped line the X,Y falls on. .IX Xref "Gnomon" .PP .Vb 7 \& | | | | Min=gnomon 2 \-\-\-\-\-\-\-\-\-\-\-\-. Max=gnomon \& | | | | 1 \-\-\-\-\-\-\-\-\-\-. | \& | | | | ... 0 \-\-\-\-\-\-\-\-o | | \& | | | \-\-\-\-\-\- 1 \-1 \-\-\-\-\-\-. | | | \& | | o\-\-\-\-\-\-\-\- 0 ... | | | | \& | \-\-\-\-\-\-\-\-\-\- \-1 | | | | \& \-\-\-\-\-\-\-\-\-\-\-\- \-2 | | | | .Ve .SS "MinAbs" .IX Subsection "MinAbs" MinAbs = min(abs(X),abs(Y)) can be interpreted geometrically as counting gnomons successively away from the origin. This is like Min above, but within the quadrant containing X,Y. .IX Xref "Gnomon" .PP .Vb 9 \& | | | | | MinAbs=gnomon counted away from the origin \& | | | | | \& 2 \-\-\- | | | \-\-\-\- 2 \& 1 \-\-\-\-\- | \-\-\-\-\-\- 1 \& 0 \-\-\-\-\-\-\-o\-\-\-\-\-\-\-\- 0 \& 1 \-\-\-\-\- | \-\-\-\-\-\- 1 \& 2 \-\-\- | | | \-\-\-\- 2 \& | | | | | \& | | | | | .Ve .SS "MaxAbs" .IX Subsection "MaxAbs" MaxAbs = max(abs(X),abs(Y)) can be interpreted geometrically as counting successive squares around the origin. .PP .Vb 7 \& +\-\-\-\-\-\-\-\-\-\-\-+ MaxAbs=which square \& | +\-\-\-\-\-\-\-+ | \& | | +\-\-\-+ | | \& | | | o | | | \& | | +\-\-\-+ | | \& | +\-\-\-\-\-\-\-+ | \& +\-\-\-\-\-\-\-\-\-\-\-+ .Ve .PP For example Math::PlanePath::SquareSpiral loops around in squares and so its MaxAbs is unchanged until it steps out to the next bigger square. .SS "Sum and Diff" .IX Subsection "Sum and Diff" \&\*(L"Sum\*(R"=X+Y and \*(L"DiffXY\*(R"=X\-Y can be interpreted geometrically as coordinates on 45\-degree diagonals. Sum is a measure up along the leading diagonal and DiffXY down an anti-diagonal, .PP .Vb 10 \& \e / \& \e s=X+Y / \& \e ^\e \& \e / \e \& \e | / v \& \e|/ * d=X\-Y \& \-\-\-o\-\-\-\- \& /|\e \& / | \e \& / | \e \& / \e \& / \e \& / \e .Ve .PP Or \*(L"Sum\*(R" can be thought of as a count of which anti-diagonal stripe contains X,Y, or a projection onto the X=Y leading diagonal. .PP .Vb 8 \& Sum \& \e = anti\-diag \& 2 numbering / / / / DiffXY \& \e \e X+Y \-1 0 1 2 = diagonal \& 1 2 / / / / numbering \& \e \e \e \-1 0 1 2 X\-Y \& 0 1 2 / / / \& \e \e \e 0 1 2 .Ve .SS "DiffYX" .IX Subsection "DiffYX" \&\*(L"DiffYX\*(R" = Y\-X is simply the negative of DiffXY. It's included to give positive values on paths which are above the X=Y leading diagonal. For example DiffXY is positive in \f(CW\*(C`CoprimeColumns\*(C'\fR which is below X=Y, whereas DiffYX is positive in \f(CW\*(C`CellularRule\*(C'\fR which is above X=Y. .SS "SumAbs" .IX Subsection "SumAbs" \&\*(L"SumAbs\*(R" = abs(X)+abs(Y) is similar to the projection described above for Sum or Diff, but SumAbs projects onto the central diagonal of whichever quadrant contains the X,Y. Or equivalently it's a numbering of anti-diagonals within that quadrant, so numbering which diamond shape the X,Y falls on. .IX Xref "Diamonds" .PP .Vb 9 \& | \& /|\e SumAbs = which diamond X,Y falls on \& / | \e \& / | \e \& \-\-\-\-\-o\-\-\-\-\- \& \e | / \& \e | / \& \e|/ \& | .Ve .PP As an example, the \f(CW\*(C`DiamondSpiral\*(C'\fR path loops around on such diamonds, so its SumAbs is unchanged until completing a loop and stepping out to the next bigger. .PP SumAbs is also a \*(L"taxi-cab\*(R" or \*(L"Manhattan\*(R" distance, being how far to travel through a square-grid city to get to X,Y. .IX Xref "Taxi cab Manhattan" .PP .Vb 1 \& SumAbs = taxi\-cab distance, by any square\-grid travel \& \& +\-\-\-\-\-o +\-\-o o \& | | | \& | +\-\-+ +\-\-\-\-\-+ \& | | | \& * * * .Ve .PP If a path is entirely X>=0,Y>=0 in the first quadrant then Sum and SumAbs are identical. .SS "AbsDiff" .IX Subsection "AbsDiff" \&\*(L"AbsDiff\*(R" = abs(X\-Y) can be interpreted geometrically as the distance away from the X=Y diagonal, measured at right-angles to that line. .PP .Vb 10 \& d=abs(X\-Y) \& ^ / X=Y line \& \e / \& \e/ \& /\e \& / \e \& |/ \e \& \-\-o\-\- \e \& /| v \& / d=abs(X\-Y) .Ve .PP If a path is entirely below the X=Y line, so X>=Y, then AbsDiff is the same as DiffXY. Or if a path is entirely above the X=Y line, so Y>=X, then AbsDiff is the same as DiffYX. .SS "Radius and RSquared" .IX Subsection "Radius and RSquared" Radius and RSquared are per \f(CW\*(C`$path\->n_to_radius()\*(C'\fR and \&\f(CW\*(C`$path\->n_to_rsquared()\*(C'\fR respectively (see \*(L"Coordinate Methods\*(R" in Math::PlanePath). .SS "TRadius and TRSquared" .IX Subsection "TRadius and TRSquared" \&\*(L"TRadius\*(R" and \*(L"TRSquared\*(R" are designed for use with points on a triangular lattice as per \*(L"Triangular Lattice\*(R" in Math::PlanePath. For points on the X axis TRSquared is the same as RSquared but off the axis Y is scaled up by factor \fBsqrt\fR\|(3). .PP Most triangular paths use \*(L"even\*(R" points X==Y mod 2 and for them TRSquared is always even. Some triangular paths such as \f(CW\*(C`KochPeaks\*(C'\fR have an offset from the origin and use \*(L"odd\*(R" points X!=Y mod 2 and for them TRSquared is odd. .SS "IntXY and FracXY" .IX Subsection "IntXY and FracXY" \&\*(L"IntXY\*(R" = int(X/Y) is the quotient from X divide Y rounded to an integer towards zero. This is like the integer part of a fraction, for example X=9,Y=4 is 9/4 = 2+1/4 so IntXY=2. Negatives are reckoned with the fraction part negated too, so \-2 1/4 is \-2\-1/4 and thus IntXY=\-2. .PP Geometrically IntXY gives which wedge of slope 1, 2, 3, etc the point X,Y falls in. For example IntXY is 3 for all points in the wedge 3Y<=X<4Y. .PP .Vb 10 \& X=Y X=2Y X=3Y X=4Y \& * \-2 * \-1 * 0 | 0 * 1 * 2 * 3 * \& * * * | * * * * \& * * * | * * * * \& * * * | * * * * \& * * * | * * * * \& * * * | * * * * \& ***|**** \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& **|** \& * * | * * \& * * | * * \& * * | * * \& * * | * * \& 2 * 1 * 0 | 0 * \-1 * \-2 .Ve .PP \&\*(L"FracXY\*(R" is the fraction part which goes with IntXY. In all cases .PP .Vb 1 \& X/Y = IntXY + FracXY .Ve .PP IntXY rounds towards zero so the remaining FracXY has the same sign as IntXY. .SS "BitAnd, BitOr, BitXor" .IX Subsection "BitAnd, BitOr, BitXor" \&\*(L"BitAnd\*(R", \*(L"BitOr\*(R" and \*(L"BitXor\*(R" treat negative X or negative Y as infinite twos-complement 1\-bits, which means for example X=\-1,Y=\-2 has X bitand Y = \-2. .PP .Vb 4 \& ...11111111 X=\-1 \& ...11111110 Y=\-2 \& \-\-\-\-\-\-\-\-\-\-\- \& ...11111110 X bitand Y = \-2 .Ve .PP This twos-complement is per \f(CW\*(C`Math::BigInt\*(C'\fR (which has bitwise operations in Perl 5.6 and up). The code here arranges the same on ordinary scalars. .PP If X or Y are not integers then the fractional parts are treated bitwise too, but currently only to limited precision. .SH "FUNCTIONS" .IX Header "FUNCTIONS" See \*(L"\s-1FUNCTIONS\*(R"\s0 in Math::NumSeq for behaviour common to all sequence classes. .ie n .IP """$seq = Math::NumSeq::PlanePathCoord\->new (planepath => $name, coordinate_type => $str)""" 4 .el .IP "\f(CW$seq = Math::NumSeq::PlanePathCoord\->new (planepath => $name, coordinate_type => $str)\fR" 4 .IX Item "$seq = Math::NumSeq::PlanePathCoord->new (planepath => $name, coordinate_type => $str)" Create and return a new sequence object. The options are .Sp .Vb 3 \& planepath string, name of a PlanePath module \& planepath_object PlanePath object \& coordinate_type string, as described above .Ve .Sp \&\f(CW\*(C`planepath\*(C'\fR can be either the module part such as \*(L"SquareSpiral\*(R" or a full class name \*(L"Math::PlanePath::SquareSpiral\*(R". .ie n .IP """$value = $seq\->ith($i)""" 4 .el .IP "\f(CW$value = $seq\->ith($i)\fR" 4 .IX Item "$value = $seq->ith($i)" Return the coordinate at N=$i in the PlanePath. .ie n .IP """$i = $seq\->i_start()""" 4 .el .IP "\f(CW$i = $seq\->i_start()\fR" 4 .IX Item "$i = $seq->i_start()" Return the first index \f(CW$i\fR in the sequence. This is the position \&\f(CW\*(C`rewind()\*(C'\fR returns to. .Sp This is \f(CW\*(C`$path\->n_start()\*(C'\fR from the PlanePath, since the i numbering is the N numbering of the underlying path. For some of the \&\f(CW\*(C`Math::NumSeq::OEIS\*(C'\fR generated sequences there may be a higher \f(CW\*(C`i_start()\*(C'\fR corresponding to a higher starting point in the \s-1OEIS,\s0 though this is slightly experimental. .ie n .IP """$str = $seq\->oeis_anum()""" 4 .el .IP "\f(CW$str = $seq\->oeis_anum()\fR" 4 .IX Item "$str = $seq->oeis_anum()" Return the A\-number (a string) for \f(CW$seq\fR in Sloane's Online Encyclopedia of Integer Sequences, or return \f(CW\*(C`undef\*(C'\fR if not in the \s-1OEIS\s0 or not known. .Sp Known A\-numbers are also presented through \f(CW\*(C`Math::NumSeq::OEIS::Catalogue\*(C'\fR. This means PlanePath related \s-1OEIS\s0 sequences can be created with \&\f(CW\*(C`Math::NumSeq::OEIS\*(C'\fR by giving their A\-number in the usual way for that module. .SH "SEE ALSO" .IX Header "SEE ALSO" Math::NumSeq, Math::NumSeq::PlanePathDelta, Math::NumSeq::PlanePathTurn, Math::NumSeq::PlanePathN, Math::NumSeq::OEIS .PP Math::PlanePath .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 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 .