1Math::PlanePath::DiamonUdsAerrmsC(o3n)tributed Perl DocuMmaetnht:a:tPiloannePath::DiamondArms(3)
2
3
4
6 Math::PlanePath::DiamondArms -- four spiral arms
7
9 use Math::PlanePath::DiamondArms;
10 my $path = Math::PlanePath::DiamondArms->new;
11 my ($x, $y) = $path->n_to_xy (123);
12
14 This path follows four spiral arms, each advancing successively in a
15 diamond pattern,
16
17 25 ... 4
18 29 14 21 36 3
19 33 18 7 10 17 32 2
20 ... 22 11 4 3 6 13 28 1
21 26 15 8 1 2 9 24 ... <- Y=0
22 30 19 12 5 20 35 -1
23 34 23 16 31 -2
24 ... 27 -3
25
26 ^
27 -3 -2 -1 X=0 1 2 3 4
28
29 Each arm makes a spiral widening out by 4 each time around, thus
30 leaving room for four such arms. Each arm loop is 64 longer than the
31 preceding loop. For example N=13 to N=85 below is 84-13=72 points, and
32 the next loop N=85 to N=221 is 221-85=136 which is an extra 64, ie.
33 72+64=136.
34
35 25 ...
36 / \ \
37 29 . 21 . . . 93
38 / \ \
39 33 . . . 17 . . . 89
40 / \ \
41 37 . . . . . 13 . . . 85
42 / / /
43 41 . . . 1 . 9 . . . 81
44 \ \ / /
45 45 . . . 5 . . . 77
46 \ /
47 49 . . . . . 73
48 \ /
49 53 . . . 69
50 \ /
51 57 . 65
52 \ /
53 61
54
55 Each arm is N=4*k+rem for a remainder rem=0,1,2,3, so sequences related
56 to multiples of 4 or with a modulo 4 pattern may fall on particular
57 arms.
58
59 The starts of each arm N=1,2,3,4 are at X=0 or 1 and Y=0 or 1,
60
61 ..
62 \
63 4 3 .. Y=1
64 / /
65 .. 1 2 <- Y=0
66 \
67 ..
68 ^ ^
69 X=0 X=1
70
71 They could be centred around the origin by taking X-1/2,Y-1/2 so for
72 example N=1 would be at -1/2,-1/2. But the it's done as N=1 at 0,0 to
73 stay in integers.
74
76 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
77 classes.
78
79 "$path = Math::PlanePath::DiamondArms->new ()"
80 Create and return a new path object.
81
82 "($x,$y) = $path->n_to_xy ($n)"
83 Return the X,Y coordinates of point number $n on the path. For "$n
84 < 1" the return is an empty list, as the path starts at 1.
85
86 Fractional $n gives a point on the line between $n and "$n+4", that
87 "$n+4" being the next point on the same spiralling arm. This is
88 probably of limited use, but arises fairly naturally from the
89 calculation.
90
91 Descriptive Methods
92 "$arms = $path->arms_count()"
93 Return 4.
94
96 Math::PlanePath, Math::PlanePath::SquareArms,
97 Math::PlanePath::DiamondSpiral
98
100 <http://user42.tuxfamily.org/math-planepath/index.html>
101
103 Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
104 Kevin Ryde
105
106 This file is part of Math-PlanePath.
107
108 Math-PlanePath is free software; you can redistribute it and/or modify
109 it under the terms of the GNU General Public License as published by
110 the Free Software Foundation; either version 3, or (at your option) any
111 later version.
112
113 Math-PlanePath is distributed in the hope that it will be useful, but
114 WITHOUT ANY WARRANTY; without even the implied warranty of
115 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
116 General Public License for more details.
117
118 You should have received a copy of the GNU General Public License along
119 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
120
121
122
123perl v5.36.0 2023-01-20 Math::PlanePath::DiamondArms(3)