1Math::PlanePath::PixelRUisnegrs(C3o)ntributed Perl DocumMeanttha:t:iPolnanePath::PixelRings(3)
2
3
4

NAME

6       Math::PlanePath::PixelRings -- pixellated concentric circles
7

SYNOPSIS

9        use Math::PlanePath::PixelRings;
10        my $path = Math::PlanePath::PixelRings->new;
11        my ($x, $y) = $path->n_to_xy (123);
12

DESCRIPTION

14       This path puts points on the pixels of concentric circles using the
15       midpoint ellipse drawing algorithm.
16
17                       63--62--61--60--59                     5
18                     /                    \
19                   64  .   40--39--38   .  58                 4
20                 /       /            \       \
21               65  .   41  23--22--21  37   .  57             3
22             /       /   /            \   \       \
23           66  .   42  24  10-- 9-- 8  20  36   .  56         2
24            |    /   /   /            \   \   \     |
25           67  43  25  11   .   3   .   7  19  35  55         1
26            |   |   |   |     /   \     |   |   |   |
27           67  44  26  12   4   1   2   6  18  34  54       Y=0
28            |   |   |   |     \   /
29           68  45  27  13   .   5   .  17  33  53  80        -1
30            |    \   \   \            /   /   /     |
31           69  .   46  28  14--15--16  32  52   .  79        -2
32             \       \   \            /   /       /
33               70  .   47  29--30--31  51   .  78            -3
34                 \       \            /       /
35                   71  .   48--49--50   .  77                -4
36                     \                    /
37                       72--73--74--75--76                    -5
38
39           -5  -4  -3  -2  -1  X=0  1   2   3   4   5
40
41       The way the algorithm works means the rings don't overlap.  Each is 4
42       or 8 pixels longer than the preceding.  If the ring follows the
43       preceding tightly then it's 4 longer, for example N=18 to N=33.  If it
44       goes wider then it's 8 longer, for example N=54 to N=80 ring.  The
45       average extra is approximately 4*sqrt(2).
46
47       The rings can be thought of as part-way between the diagonals like
48       "DiamondSpiral" and the corners like "SquareSpiral".
49
50            *           **           *****
51             *            *              *
52              *            *             *
53               *            *            *
54                *           *            *
55
56           diagonal     ring         corner
57           5 points    6 points     9 points
58
59       For example the N=54 to N=80 ring has a vertical part N=54,55,56 like a
60       corner then a diagonal part N=56,57,58,59.  In bigger rings the
61       verticals are intermingled with the diagonals but the principle is the
62       same.  The number of vertical steps determines where it crosses the
63       45-degree line, which is at R*sqrt(2) but rounded according to the
64       midpoint algorithm.
65

FUNCTIONS

67       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
68       classes.
69
70       "$path = Math::PlanePath::PixelRings->new ()"
71           Create and return a new path object.
72
73       "($x,$y) = $path->n_to_xy ($n)"
74           For "$n < 1" the return is an empty list, it being considered there
75           are no negative points.
76
77           The behaviour for fractional $n is unspecified as yet.
78
79       "$n = $path->xy_to_n ($x,$y)"
80           Return an integer point number for coordinates "$x,$y".  Each
81           integer N is considered the centre of a unit square and an "$x,$y"
82           within that square returns N.
83
84           Not every point of the plane is covered (like those marked by a "."
85           in the sample above).  If "$x,$y" is not reached then the return is
86           "undef".
87

SEE ALSO

89       Math::PlanePath, Math::PlanePath::Hypot, Math::PlanePath::MultipleRings
90

HOME PAGE

92       <http://user42.tuxfamily.org/math-planepath/index.html>
93

LICENSE

95       Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Kevin
96       Ryde
97
98       This file is part of Math-PlanePath.
99
100       Math-PlanePath is free software; you can redistribute it and/or modify
101       it under the terms of the GNU General Public License as published by
102       the Free Software Foundation; either version 3, or (at your option) any
103       later version.
104
105       Math-PlanePath is distributed in the hope that it will be useful, but
106       WITHOUT ANY WARRANTY; without even the implied warranty of
107       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
108       General Public License for more details.
109
110       You should have received a copy of the GNU General Public License along
111       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
112
113
114
115perl v5.30.1                      2020-01-30    Math::PlanePath::PixelRings(3)
Impressum