Math::PlanePath::HeptSpiralSkewed -- integer points around a skewed seven sided spiral
use Math::PlanePath::HeptSpiralSkewed; my $path = Math::PlanePath::HeptSpiralSkewed->new; my ($x, $y) = $path->n_to_xy (123);
This path makes a seven-sided spiral by cutting one corner of a square
34-33-32-31 3 | \ 35 14-13-12 30 2 | | \ \ 36 15 4--3 11 29 1 | | | \ \ \ 47 16 5 1--2 10 28 <- y=0 | | | | | 38 17 6--7--8- 9 27 -1 | | | 39 18-22-23-24-25-26 -2 | 40-41-42-43-44-... ^ -3 -2 -1 x=0 1 2 3
The path is as if around a heptagon, with the left and bottom here as two sides of the heptagon straightened out, and the flat top here skewed across to fit a square grid.
$path = Math::PlanePath::HeptSpiralSkewed->new ()
Create and return a new heptagon spiral object.
($x,$y) = $path->n_to_xy ($n)
Return the X,Y coordinates of point number $n on the path.
$n
For $n < 1 the return is an empty list, it being considered the path starts at 1.
$n < 1
$n = $path->xy_to_n ($x,$y)
Return the point number for coordinates $x,$y. $x and $y are each rounded to the nearest integer, which has the effect of treating each N in the path as centred in a square of side 1, so the entire plane is covered.
$x,$y
$x
$y
Math::PlanePath, Math::PlanePath::SquareSpiral
http://user42.tuxfamily.org/math-planepath/index.html
Math-PlanePath is Copyright 2010, 2011 Kevin Ryde
Math-PlanePath 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-PlanePath 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-PlanePath. If not, see <http://www.gnu.org/licenses/>.
To install Math::PlanePath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::PlanePath
CPAN shell
perl -MCPAN -e shell install Math::PlanePath
For more information on module installation, please visit the detailed CPAN module installation guide.