.\" 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::TriangularHypot 3pm" .TH Math::PlanePath::TriangularHypot 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::TriangularHypot \-\- points of triangular lattice in order of hypotenuse distance .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::TriangularHypot; \& my $path = Math::PlanePath::TriangularHypot\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This path visits X,Y points on a triangular \*(L"A2\*(R" lattice in order of their distance from the origin 0,0 and anti-clockwise around from the X axis among those of equal distance. .PP .Vb 1 \& 58 47 39 46 57 4 \& \& 48 34 23 22 33 45 3 \& \& 40 24 16 9 15 21 38 2 \& \& 49 25 10 4 3 8 20 44 1 \& \& 35 17 5 1 2 14 32 <\- Y=0 \& \& 50 26 11 6 7 13 31 55 \-1 \& \& 41 27 18 12 19 30 43 \-2 \& \& 51 36 28 29 37 54 \-3 \& \& 60 52 42 53 61 \-4 \& \& ^ \& \-7 \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 7 .Ve .PP The lattice is put on a square X,Y grid using every second point per \&\*(L"Triangular Lattice\*(R" in Math::PlanePath. Scaling X/2,Y*\fIsqrt\fR\|(3)/2 gives equilateral triangles of side length 1 making a distance from X,Y to the origin .PP .Vb 2 \& dist^2 = (X/2^2 + (Y*sqrt(3)/2)^2 \& = (X^2 + 3*Y^2) / 4 .Ve .PP For example N=19 at X=2,Y=\-2 is sqrt((2**2+3*\-2**2)/4) = \fIsqrt\fR\|(4) from the origin. The next smallest after that is X=5,Y=1 at \fIsqrt\fR\|(7). The key part is X^2 + 3*Y^2 as the distance measure to order the points. .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 N=14 at X=4,Y=0 is \fIsqrt\fR\|(4) from the origin, and so are the rotated X=2,Y=2 and X=\-2,Y=2 etc in other sixth segments, for a total 6 points N=14 to N=19 all the same distance. .PP Symmetry means there's a set of 6 or 12 points with the same distance, so the count of same-distance points is always a multiple of 6 or 12. There are 6 symmetric points when on the six radial lines X=0, X=Y or X=\-Y, and on the lines Y=0, X=3*Y or X=\-3*Y which are midway between them. There's 12 symmetric points for anything else, ie. anything in the twelve slices between those twelve lines. The first set of 12 equal is N=20 to N=31 all at sqrt(28). .PP There can also be further ways for the same distance to arise, as multiple solutions to X^2+3*Y^3=d^2, but the 6\-way or 12\-way symmetry means there's always a multiple of 6 or 12 in total. .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, which is X,Y one odd the other even. .PP .Vb 12 \& points => "odd" \& 69 5 \& 66 50 45 44 49 65 4 \& 58 40 28 25 27 39 57 3 \& 54 32 20 12 11 19 31 53 2 \& 36 16 6 3 5 15 35 1 \& 46 24 10 2 1 9 23 43 <\- Y=0 \& 37 17 7 4 8 18 38 \-1 \& 55 33 21 13 14 22 34 56 \-2 \& 59 41 29 26 30 42 60 \-3 \& 67 51 47 48 52 68 \-4 \& 70 \-5 \& \& ^ \& \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 .Ve .SS "All Points" .IX Subsection "All Points" Option \f(CW\*(C`points => "all"\*(C'\fR visits all integer X,Y points. .PP .Vb 1 \& points => "all" \& \& 64 59 49 44 48 58 63 3 \& 69 50 39 30 25 19 24 29 38 47 68 2 \& 51 35 20 13 8 4 7 12 18 34 46 1 \& 65 43 31 17 9 3 1 2 6 16 28 42 62 <\- Y=0 \& 52 36 21 14 10 5 11 15 23 37 57 \-1 \& 70 53 40 32 26 22 27 33 41 56 71 \-2 \& 66 60 54 45 55 61 67 \-3 \& \& ^ \& \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 .Ve .SS "Hex Points" .IX Subsection "Hex Points" Option \f(CW\*(C`points => "hex"\*(C'\fR visits X,Y points making a hexagonal grid, .PP .Vb 1 \& points => "hex" \& \& 50\-\-\-\-42 49\-\-\-\-59 5 \& / \e / \e \& 51\-\-\-\-39 27\-\-\-\-33 48 4 \& / \e / \e / \& 43 22\-\-\-\-15 21\-\-\-\-32 3 \& \e / \e / \e \& 28\-\-\-\-16 6\-\-\-\-11 26\-\-\-\-41 2 \& / \e / \e / \e \& 52\-\-\-\-34 7\-\-\-\- 3 5\-\-\-\-14 47 1 \& / \e / \e / \e / \& 60 23\-\-\-\-12 1\-\-\-\-\-2 20\-\-\-\-38 <\- Y=0 \& \e / \e / \e / \e \& 53\-\-\-\-35 8\-\-\-\- 4 10\-\-\-\-19 58 \-1 \& \e / \e / \e / \& 29\-\-\-\-17 9\-\-\-\-13 31\-\-\-\-46 \-2 \& / \e / \e / \& 44 24\-\-\-\-18 25\-\-\-\-37 \-3 \& \e / \e / \e \& 54\-\-\-\-40 30\-\-\-\-36 57 \-4 \& \e / \e / \& 55\-\-\-\-45 56\-\-\-\-61 \-5 \& \& ^ \& \-9 \-8 \-7 \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 7 8 9 .Ve .PP N=1 is at the origin X=0,Y=0, then N=2,3,4 are all at X^2+3Y^2=4 away from the origin, etc. The joining lines drawn above show the grid pattern but points are in order of distance from the origin. .PP The points are all integer X,Y with X+3Y mod 6 == 0 or 2. This is a subset of the default \*(L"even\*(R" points in that X+Y is even but with 1 of each 3 points skipped to make the hexagonal outline. .SS "Hex Rotated Points" .IX Subsection "Hex Rotated Points" Option \f(CW\*(C`points => "hex_rotated"\*(C'\fR is the same hexagonal points but rotated around so N=2 is at +60 degrees instead of on the X axis. .PP .Vb 1 \& points => "hex_rotated" \& \& \& 60\-\-\-\-50 42\-\-\-\-49 5 \& / \e / \e \& 51 33\-\-\-\-27 38\-\-\-\-48 4 \& \e / \e / \e \& 34\-\-\-\-22 15\-\-\-\-21 41 3 \& / \e / \e / \& 43\-\-\-\-28 12\-\-\-\-\-6 14\-\-\-\-26 2 \& / \e / \e / \e \& 52 16\-\-\-\-\-7 2\-\-\-\-\-5 32\-\-\-\-47 1 \& \e / \e / \e / \e \& 39\-\-\-\-23 3\-\-\-\-\-1 11\-\-\-\-20 59 <\- Y=0 \& / \e / \e / \e / \& 53 17\-\-\-\-\-8 4\-\-\-\-10 37\-\-\-\-58 \-1 \& \e / \e / \e / \& 44\-\-\-\-29 13\-\-\-\-\-9 19\-\-\-\-31 \-2 \& \e / \e / \e \& 35\-\-\-\-24 18\-\-\-\-25 46 \-3 \& / \e / \e / \& 54 36\-\-\-\-30 40\-\-\-\-57 \-4 \& \e / \e / \& 61\-\-\-\-55 45\-\-\-\-56 \-5 \& \& \& ^ \& \-9 \-8 \-7 \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 7 8 9 .Ve .PP Points are still numbered from the X axis clockwise. The sets of points at equal hypotenuse distances are the same as plain \*(L"hex\*(R" but the numbering is changed by the rotation. .PP The points visited are all integer X,Y with X+3Y mod 6 == 0 or 4. This grid can be viewed either as a +60 degree or a +180 degree rotation of the plain hex. .SS "Hex Centred Points" .IX Subsection "Hex Centred Points" Option \f(CW\*(C`points => "hex_centred"\*(C'\fR is the same hexagonal grid as hex above, but with the origin X=0,Y=0 in the centre of a hexagon, .PP .Vb 1 \& points => "hex_centred" \& \& 46\-\-\-\-45 5 \& / \e \& 39\-\-\-\-28 27\-\-\-\-38 4 \& / \e / \e \& 47\-\-\-\-29 16\-\-\-\-15 26\-\-\-\-44 3 \& / \e / \e / \e \& 48 17\-\-\-\-\-9 8\-\-\-\-14 43 2 \& \e / \e / \e / \& 30\-\-\-\-18 3\-\-\-\-\-2 13\-\-\-\-25 1 \& / \e / \e / \e \& 40 10\-\-\-\-\-4 . 1\-\-\-\-\-7 37 <\- Y=0 \& \e / \e / \e / \& 31\-\-\-\-19 5\-\-\-\-\-6 24\-\-\-\-36 \-1 \& / \e / \e / \e \& 49 20\-\-\-\-11 12\-\-\-\-23 54 \-2 \& \e / \e / \e / \& 50\-\-\-\-32 21\-\-\-\-22 35\-\-\-\-53 \-3 \& \e / \e / \& 41\-\-\-\-33 34\-\-\-\-42 \-4 \& \e / \& 51\-\-\-\-52 \-5 \& \& ^ \& \-8 \-7 \-6 \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 7 8 9 .Ve .PP N=1,2,3,4,5,6 are all at X^2+3Y^2=4 away from the origin, then N=7,8,9,10,11,12, etc. The points visited are all integer X,Y with X+3Y mod 6 == 2 or 4. .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::TriangularHypot\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::TriangularHypot\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::TriangularHypot->new ()" .PD 0 .ie n .IP """$path = Math::PlanePath::TriangularHypot\->new (points => $str)""" 4 .el .IP "\f(CW$path = Math::PlanePath::TriangularHypot\->new (points => $str)\fR" 4 .IX Item "$path = Math::PlanePath::TriangularHypot->new (points => $str)" .PD Create and return a new hypot path object. The \f(CW\*(C`points\*(C'\fR option can be .Sp .Vb 6 \& "even" only points with X+Y even (the default) \& "odd" only points with X+Y odd \& "all" all integer X,Y \& "hex" hexagonal X+3Y==0,2 mod 6 \& "hex_rotated" hexagonal X+3Y==0,4 mod 6 \& "hex_centred" hexagonal X+3Y==2,4 mod 6 .Ve .Sp Create and return a new triangular hypot 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 < 1\*(C'\fR the return is an empty list as 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 "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 5 \& points="even" (the default) \& A003136 norms (X^2+3*Y^2)/4 which occur \& A004016 count of points of norm==n \& A035019 skipping zero counts \& A088534 counting only in the twelfth 0<=X<=Y .Ve .PP The counts in these sequences are expressed as norm = x^2+x*y+y^2. That x,y is related to the \*(L"even\*(R" X,Y on the path here by a \-45 degree rotation, .PP .Vb 2 \& x = (Y\-X)/2 X = 2*(x+y) \& y = (X+Y)/2 Y = 2*(y\-x) \& \& norm = x^2+x*y+y^2 \& = ((Y\-X)/2)^2 + (Y\-X)/2 * (X+Y)/2 + ((X+Y)/2)^2 \& = (X^2 + 3*Y^2) / 4 .Ve .PP The X^2+3*Y^2 is the dist^2 described above for equilateral triangles of unit side. The factor of /4 scales the distance but of course doesn't change the sets of points of the same distance. .PP .Vb 4 \& points="all" \& A092572 norms X^2+3*Y^2 which occur \& A158937 norms X^2+3*Y^2 which occur, X>0,Y>0 with repeats \& A092573 count of points norm==n for X>0,Y>0 \& \& A092574 norms X^2+3*Y^2 which occur for X>0,Y>0, gcd(X,Y)=1 \& A092575 count of points norm==n for X>0,Y>0, gcd(X,Y)=1 \& ie. X,Y no common factor .Ve .PP .Vb 3 \& points="hex" \& A113062 count of points norm=X^2+3*Y^2=4*n (theta series) \& A113063 divided by 3 \& \& points="hex_centred" \& A217219 count of points norm=X^2+3*Y^2=4*n (theta series) .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::Hypot, Math::PlanePath::HypotOctant, Math::PlanePath::PixelRings, Math::PlanePath::HexSpiral .SH "HOME PAGE" .IX Header "HOME PAGE" .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 .