1Math::PlanePath::Rows(3U)ser Contributed Perl DocumentatiMoanth::PlanePath::Rows(3)
2
3
4
6 Math::PlanePath::Rows -- points in fixed-width rows
7
9 use Math::PlanePath::Rows;
10 my $path = Math::PlanePath::Rows->new (width => 20);
11 my ($x, $y) = $path->n_to_xy (123);
12
14 This path is rows of a given fixed width. For example width=7 is
15
16 width => 7
17
18 3 | 22 23 24 ...
19 2 | 15 16 17 18 19 20 21
20 1 | 8 9 10 11 12 13 14
21 Y=0 | 1 2 3 4 5 6 7
22 -------------------------------
23 X=0 1 2 3 4 5 6
24
25 N Start
26 The default is to number points starting N=1 as shown above. An
27 optional "n_start" can give a different start, with the same shape.
28 For example to start at 0,
29
30 n_start => 0, width => 7
31
32 3 | 21 22 23 24 ...
33 2 | 14 15 16 17 18 19 20
34 1 | 7 8 9 10 11 12 13
35 Y=0 | 0 1 2 3 4 5 6
36 -------------------------------
37 X=0 1 2 3 4 5 6
38
39 The only effect is to push the N values around by a constant amount.
40 It might help match coordinates with something else zero-based.
41
43 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
44 classes.
45
46 "$path = Math::PlanePath::Rows->new (width => $w)"
47 "$path = Math::PlanePath::Rows->new (width => $w, n_start => $n)"
48 Create and return a new path object. A "width" parameter must be
49 supplied.
50
51 "($x,$y) = $path->n_to_xy ($n)"
52 Return the X,Y coordinates of point number $n in the path.
53
54 "$n = $path->xy_to_n ($x,$y)"
55 Return the point number for coordinates "$x,$y".
56
57 $x and $y are rounded to the nearest integers, which has the effect
58 of treating each point in the path as a square of side 1, so a
59 column -0.5 <= x < width+0.5 and y>=-0.5 is covered.
60
61 "($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)"
62 The returned range is exact, meaning $n_lo and $n_hi are the
63 smallest and biggest in the rectangle.
64
66 Math::PlanePath, Math::PlanePath::Columns
67
69 <http://user42.tuxfamily.org/math-planepath/index.html>
70
72 Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde
73
74 This file is part of Math-PlanePath.
75
76 Math-PlanePath is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
78 the Free Software Foundation; either version 3, or (at your option) any
79 later version.
80
81 Math-PlanePath is distributed in the hope that it will be useful, but
82 WITHOUT ANY WARRANTY; without even the implied warranty of
83 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
84 General Public License for more details.
85
86 You should have received a copy of the GNU General Public License along
87 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
88
89
90
91perl v5.28.0 2017-12-03 Math::PlanePath::Rows(3)