NAME
Math::PlanePath::MathImageHypot -- points by hypotenuse distance
SYNOPSIS
use Math::PlanePath::MathImageHypot;
my $path = Math::PlanePath::MathImageHypot->new;
my ($x, $y) = $path->n_to_xy (123);
DESCRIPTION
In progresss ... the current implementation is very slack.
This path takes integer points X<0,Y<0 in order of their distance from the origin 0,0, that distance being the hypotenuse sqrt(X^2+Y^2).
9 73 75 79 83 85
8 58 62 64 67 71 81 ...
7 45 48 52 54 61 69 78 86
6 35 37 39 43 50 56 65 77 88
5 26 28 30 33 41 47 55 68 80
4 17 19 22 25 31 40 49 60 70 84
3 11 13 15 20 24 32 42 53 66 82
2 6 8 9 14 21 29 38 51 63 76
1 3 4 7 12 18 27 36 46 59 74
Y=0 1 2 5 10 16 23 34 44 57 72
X=0 1 2 3 4 5 6 7 8 9 ...
For example N=37 is at X=1,Y=6 which is sqrt(1*1+6*6) = sqrt(37) from the origin. The next closest to the origin is X=6,Y=2 at sqrt(40). In general it's the sums of two squares X^2+Y^2 taken in order from smallest to biggest.
Points X,Y and swapped Y,X are the same distance from the origin. The one with bigger X is taken first, then the swapped Y,X (as long as X!=Y). For example N=21 is X=4,Y=2 and N=22 is X=2,Y=4.
FUNCTIONS
$path = Math::PlanePath::MathImageHypot->new ()
-
Create and return a new path object.
($x,$y) = $path->n_to_xy ($n)
-
Return the x,y coordinates of point number
$n
on the path.For
$n < 1
the return is an empty list, it being considered the first point at X=0,Y=0 is N=1. $n = $path->xy_to_n ($x,$y)
-
Return an integer point number for coordinates
$x,$y
. Each integer N is considered the centre of a unit square and an$x,$y
within that square returns N.
SEE ALSO
Math::PlanePath, Math::PlanePath::PixelRings
HOME PAGE
http://user42.tuxfamily.org/math-image/index.html
LICENSE
Math-Image is Copyright 2011 Kevin Ryde
Math-Image is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-Image is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-Image. If not, see <http://www.gnu.org/licenses/>.