The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::PlanePath::HeptSpiralSkewed -- integer points around a skewed seven sided spiral

SYNOPSIS

 use Math::PlanePath::HeptSpiralSkewed;
 my $path = Math::PlanePath::HeptSpiralSkewed->new;
 my ($x, $y) = $path->n_to_xy (123);

DESCRIPTION

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.

FUNCTIONS

See "FUNCTIONS" in Math::PlanePath for the behaviour common to all path classes.

$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.

For $n < 1 the return is an empty list, it being considered the path starts at 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.

SEE ALSO

Math::PlanePath, Math::PlanePath::SquareSpiral

HOME PAGE

http://user42.tuxfamily.org/math-planepath/index.html

LICENSE

Copyright 2010, 2011, 2012 Kevin Ryde

This file is part of Math-PlanePath.

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/>.