Math::PlanePath::Rows3pm
Usage
use Math::PlanePath::Rows;my $path = Math::PlanePath::Rows->new (width => 20);my ($x, $y) = $path->n_to_xy (123);
Overview
This path is rows of a given fixed width. For example width=7 is
width => 73 | 22 23 24 ...2 | 15 16 17 18 19 20 211 | 8 9 10 11 12 13 14Y=0 | 1 2 3 4 5 6 7-------------------------------X=0 1 2 3 4 5 6
N Start
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 => 73 | 21 22 23 24 ...2 | 14 15 16 17 18 19 201 | 7 8 9 10 11 12 13Y=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.
Functions
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
$nin the path.
- "$n = $path->xy_to_n ($x,$y)"
-
Return the point number for coordinates
"$x,$y".$xand$yare 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_loand$n_hiare the smallest and biggest in the rectangle.
Home page
<http://user42.tuxfamily.org/math-planepath/index.html>
Releases
6 releases since Debian 8 (Jessie); the text changed 3 times.