.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" 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 turned on, 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Math::PlanePath::Hypot 3pm" .TH Math::PlanePath::Hypot 3pm "2014-08-30" "perl v5.20.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Math::PlanePath::Hypot \-\- points in order of hypotenuse distance .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::Hypot; \& my $path = Math::PlanePath::Hypot\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This path visits integer points X,Y in order of their distance from the origin 0,0, or anti-clockwise from the X axis among those of equal distance, .PP .Vb 11 \& 84 73 83 5 \& 74 64 52 47 51 63 72 4 \& 75 59 40 32 27 31 39 58 71 3 \& 65 41 23 16 11 15 22 38 62 2 \& 85 53 33 17 7 3 6 14 30 50 82 1 \& 76 48 28 12 4 1 2 10 26 46 70 <\- Y=0 \& 86 54 34 18 8 5 9 21 37 57 89 \-1 \& 66 42 24 19 13 20 25 45 69 \-2 \& 77 60 43 35 29 36 44 61 81 \-3 \& 78 67 55 49 56 68 80 \-4 \& 87 79 88 \-5 \& \& ^ \& \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 .Ve .PP For example N=58 is at X=4,Y=\-1 is sqrt(4*4+1*1) = sqrt(17) from the origin. The next furthest from the origin is X=3,Y=3 at sqrt(18). .PP See \f(CW\*(C`TriangularHypot\*(C'\fR for points in order of X^2+3*Y^2, or \f(CW\*(C`DiamondSpiral\*(C'\fR and \f(CW\*(C`PyrmaidSides\*(C'\fR in order of plain sum X+Y. .SS "Equal Distances" .IX Subsection "Equal Distances" Points with the same distance are taken in anti-clockwise order around from the X axis. For example X=3,Y=1 is sqrt(10) from the origin, as are the swapped X=1,Y=3, and X=\-1,Y=3 etc in other quadrants, for a total 8 points N=30 to N=37 all the same distance. .PP When one of X or Y is 0 there's no negative, so just four negations like N=10 to 13 points X=2,Y=0 through X=0,Y=\-2. Or on the diagonal X==Y there's no swap, so just four like N=22 to N=25 points X=3,Y=3 through X=3,Y=\-3. .PP There can be more than one way for the same distance to arise. A Pythagorean triple like 3^2 + 4^2 == 5^2 has 8 points from the 3,4, then 4 points from the 5,0 giving a total 12 points N=70 to N=81. Other combinations like 20^2 + 15^2 == 24^2 + 7^2 occur too, and also with more than two different ways to have the same sum. .SS "Multiples of 4" .IX Subsection "Multiples of 4" The first point of a given distance from the origin is either on the X axis or somewhere in the first octant. The row Y=1 just above the axis is the first of its equals from X>=2 onwards, and similarly further rows for big enough X. .PP There's always a multiple of 4 many points with the same distance so the first point has N=4*k+2, and similarly on the negative X side N=4*j, for some k or j. If you plot the prime numbers on the path then those even N's (composites) are gaps just above the positive X axis, and on or just below the negative X axis. .SS "Circle Lattice" .IX Subsection "Circle Lattice" Gauss's circle lattice problem asks how many integer X,Y points there are within a circle of radius R. .PP The points on the X axis N=2,10,26,46, etc are the first for which X^2+Y^2==R^2 (integer X==R). Adding option \f(CW\*(C`n_start=>0\*(C'\fR to make them each 1 less gives the number of points strictly inside, ie. X^2+Y^2 < R^2. .PP The last point satisfying X^2+Y^2==R^2 is either in the octant below the X axis, or is on the negative Y axis. Those N's are the number of points X^2+Y^2<=R^2, Sloane's A000328. .PP When that A000328 sequence is plotted on the path a straight line can be seen in the fourth quadrant extending down just above the diagonal. It arises from multiples of the Pythagorean 3^2 + 4^2, first X=4,Y=\-3, then X=8,Y=\-6, etc X=4*k,Y=\-3*k. But sometimes the multiple is not the last among those of that 5*k radius, so there's gaps in the line. For example 20,\-15 is not the last since because 24,\-7 is also 25 away from the origin. .SS "Even Points" .IX Subsection "Even Points" Option \f(CW\*(C`points => "even"\*(C'\fR visits just the even points, meaning the sum X+Y even, so X,Y both even or both odd. .PP .Vb 1 \& points => "even" \& \& 52 40 39 51 5 \& 47 32 23 31 46 4 \& 53 27 16 15 26 50 3 \& 33 11 7 10 30 2 \& 41 17 3 2 14 38 1 \& 24 8 1 6 22 <\- Y=0 \& 42 18 4 5 21 45 \-1 \& 34 12 9 13 37 \-2 \& 54 28 19 20 29 57 \-3 \& 48 35 25 36 49 \-4 \& 55 43 44 56 \-5 \& \& ^ \& \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 .Ve .PP Even points can be mapped to all points by a 45 degree rotate and flip. N=1,6,22,etc on the X axis here is on the X=Y diagonal of all-points. And conversely N=1,2,10,26,etc on the X=Y diagonal here is the X axis of all-points. .PP The sets of points with equal hypotenuse are the same in the even and all, but the flip takes them in a reversed order. .SS "Odd Points" .IX Subsection "Odd Points" Option \f(CW\*(C`points => "odd"\*(C'\fR visits just the odd points, meaning sum X+Y odd, so X,Y one odd the other even. .PP .Vb 1 \& points => "odd" \& \& \& 71 55 54 70 6 \& 63 47 36 46 62 5 \& 64 37 27 26 35 61 4 \& 72 38 19 14 18 34 69 3 \& 48 20 7 6 17 45 2 \& 56 28 8 2 5 25 53 1 \& 39 15 3 + 1 13 33 <\- Y=0 \& 57 29 9 4 12 32 60 \-1 \& 49 21 10 11 24 52 \-2 \& 73 40 22 16 23 44 76 \-3 \& 65 41 30 31 43 68 \-4 \& 66 50 42 51 67 \-5 \& 74 58 59 75 \-6 \& \& ^ \& \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 .Ve .PP Odd points can be mapped to all points by a 45 degree rotate and a shift X\-1,Y+1 to put N=1 at the origin. The effect of that shift is as if the hypot measure in \*(L"all\*(R" points was (X\-1/2)^2+(Y\-1/2)^2 and for that reason the sets of points with equal hypots are not the same in odd and all. .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::Hypot\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::Hypot\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::Hypot->new ()" .PD 0 .ie n .IP """$path = Math::PlanePath::Hypot\->new (points => $str), n_start => $n""" 4 .el .IP "\f(CW$path = Math::PlanePath::Hypot\->new (points => $str), n_start => $n\fR" 4 .IX Item "$path = Math::PlanePath::Hypot->new (points => $str), n_start => $n" .PD Create and return a new hypot path object. The \f(CW\*(C`points\*(C'\fR option can be .Sp .Vb 3 \& "all" all integer X,Y (the default) \& "even" only points with X+Y even \& "odd" only points with X+Y odd .Ve .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 < 1\*(C'\fR the return is an empty list, it being considered the first point at X=0,Y=0 is N=1. .Sp Currently it's unspecified what happens if \f(CW$n\fR is not an integer. Successive points are a fair way apart, so it may not make much sense to say give an X,Y position in between the integer \f(CW$n\fR. .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 an integer point number for coordinates \f(CW\*(C`$x,$y\*(C'\fR. Each integer N is considered the centre of a unit square and an \f(CW\*(C`$x,$y\*(C'\fR within that square returns N. .Sp For \*(L"even\*(R" and \*(L"odd\*(R" options only every second square in the plane has an N and if \f(CW\*(C`$x,$y\*(C'\fR is a position not covered then the return is \f(CW\*(C`undef\*(C'\fR. .SH "FORMULAS" .IX Header "FORMULAS" The calculations are not particularly efficient currently. Private arrays are built similar to what's described for \f(CW\*(C`HypotOctant\*(C'\fR, but with replication for negative and swapped X,Y. .SH "OEIS" .IX Header "OEIS" Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include .Sp .RS 4 (etc) .RE .PP .Vb 2 \& points="all", n_start=0 \& A051132 N on X axis, being count points norm < X^2 \& \& points="odd" \& A005883 count of points with norm==4*n+1 .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::HypotOctant, Math::PlanePath::TriangularHypot, Math::PlanePath::PixelRings, Math::PlanePath::PythagoreanTree .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 .