Math::PlanePath::AztecDiamondRings -- rings around an Aztec diamond shape
use Math::PlanePath::AztecDiamondRings; my $path = Math::PlanePath::AztecDiamondRings->new; my ($x, $y) = $path->n_to_xy (123);
This path makes rings around an Aztec diamond shape,
67 66 5 68 46 45 65 4 69 47 29 28 44 64 3 70 48 30 16 15 27 43 63 2 71 49 31 17 7 6 14 26 42 62 1 72 50 32 18 8 2 1 5 13 25 41 61 <- Y=0 73 51 33 19 9 3 4 12 24 40 60 84 -1 74 52 34 20 10 11 23 39 59 83 -2 75 53 35 21 22 38 58 82 -3 76 54 36 37 57 81 -4 77 55 56 80 -5 78 79 -6 ^ -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5
This is very similar to the DiamondSpiral, but has all four corners flattened to 2 vertical or horizontal, instead of just one in the DiamondSpiral. This is only a small change to the alignment of numbers in the sides, but is more symmetric.
The hexagonal numbers 1,6,15,28,45,66,etc, k*(2k-1), are the vertical at X=0 going upwards. The hexagonal numbers of the "second kind" 3,10,21,36,55,78, etc k*(2k+1), are the vertical at X=-1 going downwards. Combining those two is the triangular numbers 3,6,10,15,21,etc, k*(k+1)/2, alternately on one line and the other.
See "FUNCTIONS" in Math::PlanePath for the behaviour common to all path classes.
$path = Math::PlanePath::AztecDiamondRings->new ()
Create and return a new Aztec diamond 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 point in the path as a square of side 1, so the entire plane is covered.
$x,$y
$x
$y
($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)
The returned range is exact, meaning $n_lo and $n_hi are the smallest and biggest in the rectangle.
$n_lo
$n_hi
Math::PlanePath, Math::PlanePath::DiamondSpiral
http://user42.tuxfamily.org/math-planepath/index.html
Copyright 2011 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/>.
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.