.\" 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::CornerAlternating 3pm" .TH Math::PlanePath::CornerAlternating 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::CornerAlternating \-\- points shaped around a corner alternately .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::CornerAlternating; \& my $path = Math::PlanePath::CornerAlternating\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This path is points in layers around a square outwards from a corner in the first quadrant, alternately upward or downward. Each row/column \&\*(L"gnomon\*(R" added to a square makes a one-bigger square. .IX Xref "Gnomon" .PP .Vb 11 \& 4 | 17\-\-18\-\-19\-\-20\-\-21 ... \& | | | | \& 3 | 16\-\-15\-\-14\-\-13 22 29 \& | | | | \& 2 | 5\-\-\-6\-\-\-7 12 23 28 \& | | | | | | \& 1 | 4\-\-\-3 8 11 24 27 \& | | | | | | \& Y=0 | 1\-\-\-2 9\-\-10 25\-\-26 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& X=0 1 2 3 4 5 .Ve .PP This is like the Corner path, but here gnomons go back and forward and in particular so points are always a unit step apart. .SS "Wider" .IX Subsection "Wider" An optional \f(CW\*(C`wider => $integer\*(C'\fR makes the path wider horizontally, becoming a rectangle. For example .PP .Vb 11 \& 4 | 29\-\-30\-\-31\-\-32\-\-33\-\-34\-\-35\-\-36 ... \& | | | | \& 3 | 28\-\-27\-\-26\-\-25\-\-24\-\-23\-\-22 37 44 wider => 3 \& | | | | \& 2 | 11\-\-12\-\-13\-\-14\-\-15\-\-16 21 38 43 \& | | | | | | \& 1 | 10\-\-\-9\-\-\-8\-\-\-7\-\-\-6 17 20 39 42 \& | | | | | | \& Y=0 | 1\-\-\-2\-\-\-3\-\-\-4\-\-\-5 18\-\-19 40\-\-41 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& X=0 1 2 3 4 5 6 7 8 .Ve .PP Each gnomon has the horizontal part \f(CW\*(C`wider\*(C'\fR many steps longer. For wider=3 shown, the additional points are 2,3,4 in the first row, then 5..10 are the next gnomon. Each gnomon is still 2 longer than the previous since this widening is a constant amount in each. .SS "N Start" .IX Subsection "N Start" The default is to number points starting N=1 as shown above. An optional \&\f(CW\*(C`n_start\*(C'\fR can give a different start with the same shape etc. For example to start at 0, .PP .Vb 7 \& 4 | 16 17 18 19 20 \& 3 | 15 14 13 12 21 n_start => 0 \& 2 | 4 5 6 11 22 \& 1 | 3 2 7 10 23 \& Y=0 | 0 1 8 9 24 \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& X=0 1 2 3 4 .Ve .PP With Nstart=0, the pronic numbers are on the X=Y leading diagonal. .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::CornerAlternating\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::CornerAlternating\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::CornerAlternating->new ()" .PD 0 .ie n .IP """$path = Math::PlanePath::CornerAlternating\->new (wider => $w, n_start => $n)""" 4 .el .IP "\f(CW$path = Math::PlanePath::CornerAlternating\->new (wider => $w, n_start => $n)\fR" 4 .IX Item "$path = Math::PlanePath::CornerAlternating->new (wider => $w, n_start => $n)" .PD Create and return a new path object. .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. .Sp For \f(CW\*(C`$n < n_start()\*(C'\fR the return is an empty list. Fractional \f(CW$n\fR gives an X,Y position along a straight line between the integer positions. .ie n .IP """$n = $path\->xy_to_n ($x,$y)""" 4 .el .IP "\f(CW$n = $path\->xy_to_n ($x,$y)\fR" 4 .IX Item "$n = $path->xy_to_n ($x,$y)" Return the point number for coordinates \f(CW\*(C`$x,$y\*(C'\fR. .Sp \&\f(CW$x\fR and \f(CW$y\fR are each rounded to the nearest integer, which has the effect of treating each point as a square of side 1, so the quadrant x>=\-0.5 and y>=\-0.5 is entirely covered. .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)" The returned range is exact, meaning \f(CW$n_lo\fR and \f(CW$n_hi\fR are the smallest and biggest in the rectangle. .SH "FORMULAS" .IX Header "FORMULAS" Most calculations are similar to the Corner path (without the 0.5 fractional part), and a reversal applied when the d gnomon number is odd. When wider>0, that reversal must allow for the horizontals and verticals different lengths. .SS "Rectangle N Range" .IX Subsection "Rectangle N Range" For \f(CW\*(C`rect_to_n_range()\*(C'\fR, the largest gnomon is either the top or right of the rectangle, depending where the top right corner x2,y2 falls relative to the leading diagonal, .PP .Vb 7 \& | A\-\-\-B / x2y2 \& | | |/ top | +\-\-\-\-\-\-B right \& | | | row | | / | side \& | | /| biggest | | / | biggest \& | +\-\-\-+ gnomon | +\-\-\-\-\-\-C gnomon \& | / | / \& +\-\-\-\-\-\-\-\-\- +\-\-\-\-\-\-\-\-\-\-\- .Ve .PP Then the maximum is at A or B, or B or C according as which way that gnomon goes, so odd or even. .PP If it happens that B is on the diagonal, so x2=y2, then it's either A or C according as the gnomon odd or even .PP .Vb 7 \& | / \& | A\-\-\-\-+ x2=y2 \& | | /| \& | | / | \& | +\-\-\-\-C \& | / \& +\-\-\-\-\-\-\-\-\-\-\- .Ve .PP For wider > 0, the diagonal shifts across so that x2\-wider <=> y2 is the relevant test. .SH "OEIS" .IX Header "OEIS" This path is in Sloane's Online Encyclopedia of Integer Sequences as, .Sp .RS 4 (etc) .RE .PP .Vb 10 \& wider=0, n_start=1 (the defaults) \& A220603 X+1 coordinate \& A220604 Y+1 coordinate \& A213088 X+Y sum \& A081346 N on X axis \& A081345 N on Y axis \& A002061 N on X=Y diagonal, extra initial 1 \& A081344 permutation N by diagonals \& A194280 inverse \& A020703 permutation N at transpose Y,X \& \& A027709 boundary length of N unit squares \& A078633 grid sticks of N points \& \& n_start=0 \& A319290 X coordinate \& A319289 Y coordinate \& A319514 Y,X coordinate pairs \& A329116 X\-Y diff \& A053615 abs(X\-Y) diff \& A000196 max(X,Y), being floor(sqrt(N)) \& A339265 dX\-dY increments (runs +1,\-1) \& A002378 N on X=Y diagonal, pronic numbers \& A220516 permutation N by diagonals \& \& n_start=2 \& A014206 N on X=Y diagonal, pronic+2 \& \& wider=1, n_start=1 \& A081347 N on X axis \& A081348 N on Y axis \& A080335 N on X=Y diagonal \& A093650 permutation N by diagonals \& \& wider=1, n_start=0 \& A180714 X\-Y diff \& \& wider=2, n_start=1 \& A081350 N on X axis \& A081351 N on Y axis \& A081352 N on X=Y diagonal \& A081349 permutation N by diagonals .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::Corner, Math::PlanePath::DiagonalsAlternating .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2021 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 .