NAME
Math::PlanePath::TriangleSpiralSkewed -- integer points drawn around a skewed equilateral triangle
SYNOPSIS
use Math::PlanePath::TriangleSpiralSkewed;
my $path = Math::PlanePath::TriangleSpiralSkewed->new;
my ($x, $y) = $path->n_to_xy (123);
DESCRIPTION
This path makes an spiral shaped as an equilateral triangle (each side the same length), but skewed to the left to fit on a square grid,
16 4
17 15 3
18 4 14 2
19 5 3 13 1
20 6 1 2 12 ... <- y=0
21 7 8 9 10 11 30 -1
22 23 24 25 26 27 28 29 -2
^
-2 -1 x=0 1 2 3 4 5
The properties are the same as the spread-out TriangleSpiral. The triangle numbers fall on straight lines as the do in the TriangleSpiral but the skew means the top corner goes up at an angle to the vertical and the left and right downwards are different angles plotted (but are symmetric by N count).
FUNCTIONS
$path = Math::PlanePath::TriangleSpiralSkewed->new ()
-
Create and return a new square 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::TriangleSpiral
HOME PAGE
http://user42.tuxfamily.org/math-planepath/index.html
LICENSE
Math-PlanePath is Copyright 2010 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/>.