Math::PlanePath::Rows -- points in fixed-width rows
use Math::PlanePath::Rows; my $path = Math::PlanePath::Rows->new (width => 20); my ($x, $y) = $path->n_to_xy (123);
This path is rows of a given fixed width. For example width=7 is
width => 7 3 | 22 23 24 ... 2 | 15 16 17 18 19 20 21 1 | 8 9 10 11 12 13 14 Y=0 | 1 2 3 4 5 6 7 ------------------------------- X=0 1 2 3 4 5 6
The default is to number points starting N=1 as shown above. An optional n_start
can give a different start, with the same shape. For example to start at 0,
n_start => 0, width => 7 3 | 21 22 23 24 ... 2 | 14 15 16 17 18 19 20 1 | 7 8 9 10 11 12 13 Y=0 | 0 1 2 3 4 5 6 ------------------------------- X=0 1 2 3 4 5 6
The only effect is to push the N values around by a constant amount. It might help match coordinates with something else zero-based.
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.
$path = Math::PlanePath::Rows->new (width => $w)
$path = Math::PlanePath::Rows->new (width => $w, n_start => $n)
Create and return a new path object. A width
parameter must be supplied.
($x,$y) = $path->n_to_xy ($n)
Return the X,Y coordinates of point number $n
in the path.
$n = $path->xy_to_n ($x,$y)
Return the point number for coordinates $x,$y
.
$x
and $y
are rounded to the nearest integers, which has the effect of treating each point in the path as a square of side 1, so a column -0.5 <= x < width+0.5 and y>=-0.5 is covered.
($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.
Math::PlanePath, Math::PlanePath::Columns
http://user42.tuxfamily.org/math-planepath/index.html
Copyright 2010, 2011, 2012, 2013, 2014, 2015 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/>.