Math::PlanePath::Columns3pm
Usage
use Math::PlanePath::Columns;my $path = Math::PlanePath::Columns->new;my ($x, $y) = $path->n_to_xy (123);
Overview
This path is columns of a given fixed height. For example height 5 would be
|4 | 5 10 15 20 <--- height==53 | 4 9 14 192 | 3 8 13 181 | 2 7 12 17 ...Y=0 | 1 6 11 16 21----------------------X=0 1 2 3 4 ...
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, height => 54 | 4 9 14 193 | 3 8 13 182 | 2 7 12 171 | 1 6 11 16 ...Y=0 | 0 5 10 15 20----------------------X=0 1 2 3 4 ...
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::Columns->new (height => $h)"
- "$path = Math::PlanePath::Columns->new (height => $h, n_start => $n)"
-
Create and return a new path object. A
"height"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 rectangle$x>= -0.5 and -0.5 <= y < height+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.