1Math::PlanePath::SacksSUpsierralC(o3n)tributed Perl DocuMmaetnht:a:tPiloannePath::SacksSpiral(3)
2
3
4

NAME

6       Math::PlanePath::SacksSpiral -- circular spiral squaring each
7       revolution
8

SYNOPSIS

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

DESCRIPTION

15       The Sacks spiral by Robert Sacks is an Archimedean spiral with points N
16       placed on the spiral so the perfect squares fall on a line going to the
17       right.  Read more at
18
19           <http://www.numberspiral.com>
20
21       An Archimedean spiral means radial distance a constant factor of the
22       angle, and so each loop a constant distance out from the preceding
23       loop, in this case 1 unit out.  The polar coordinates are
24
25           R = sqrt(N)
26           theta = sqrt(N) * 2pi
27
28       which comes out roughly as
29
30                           18
31                 19   11        10  17
32                            5
33
34           20  12  6   2
35                          0  1   4   9  16  25
36
37                          3
38             21   13   7        8
39                                    15   24
40                           14
41                      22        23
42
43       The X,Y positions returned are fractional, except for the perfect
44       squares on the positive X axis at X=0,1,2,3,etc.  The perfect squares
45       are the closest points, at 1 unit apart.  Other points are a little
46       further apart.
47
48       The arms going to the right like N=5,10,17,etc or N=8,15,24,etc are
49       constant offsets from the perfect squares, ie. d^2 + c for positive or
50       negative integer c.  To the left the central arm N=2,6,12,20,etc is the
51       pronic numbers d^2 + d = d*(d+1), half way between the successive
52       perfect squares.  Other arms going to the left are offsets from that,
53       ie. d*(d+1) + c for integer c.
54
55       Euler's quadratic d^2+d+41 is one such arm going left.  Low values loop
56       around a few times before straightening out at about y=-127.  This
57       quadratic has relatively many primes and in a plot of primes on the
58       spiral it can be seen standing out from its surrounds.
59
60       Plotting various quadratic sequences of points can form attractive
61       patterns.  For example the triangular numbers k*(k+1)/2 come out as
62       spiral arcs going clockwise and anti-clockwise.
63
64       See examples/sacks-xpm.pl for a complete program plotting the spiral
65       points to an XPM image.
66

FUNCTIONS

68       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
69       classes.
70
71       "$path = Math::PlanePath::SacksSpiral->new ()"
72           Create and return a new path object.
73
74       "($x,$y) = $path->n_to_xy ($n)"
75           Return the X,Y coordinates of point number $n on the path.
76
77           $n can be any value "$n >= 0" and fractions give positions on the
78           spiral in between the integer points.
79
80           For "$n < 0" the return is an empty list, it being considered there
81           are no negative points in the spiral.
82
83       "$rsquared = $path->n_to_rsquared ($n)"
84           Return the radial distance R^2 of point $n, or "undef" if there's
85           no point $n.  This is simply $n itself, since R=sqrt(N).
86
87       "$n = $path->xy_to_n ($x,$y)"
88           Return an integer point number for coordinates "$x,$y".  Each
89           integer N is considered the centre of a circle of diameter 1 and an
90           "$x,$y" within that circle returns N.
91
92           The unit spacing of the spiral means those circles don't overlap,
93           but they also don't cover the plane and if "$x,$y" is not within
94           one then the return is "undef".
95
96   Descriptive Methods
97       "$dx = $path->dx_minimum()"
98       "$dx = $path->dx_maximum()"
99       "$dy = $path->dy_minimum()"
100       "$dy = $path->dy_maximum()"
101           dX and dY have minimum -pi=-3.14159 and maximum pi=3.14159.  The
102           loop beginning at N=2^k is approximately a polygon of 2k+1 many
103           sides and radius R=k.  Each side is therefore
104
105               side = sin(2pi/(2k+1)) * k
106                   -> 2pi/(2k+1) * k
107                   -> pi
108
109       "$str = $path->figure ()"
110           Return "circle".
111

FORMULAS

113   Rectangle to N Range
114       R=sqrt(N) here is the same as in the "TheodorusSpiral" and the code is
115       shared here.  See "Rectangle to N Range" in
116       Math::PlanePath::TheodorusSpiral.
117
118       The accuracy could be improved here by taking into account the polar
119       angle of the corners which are candidates for the maximum radius.  On
120       the X axis the stripes of N are from X-0.5 to X+0.5, but up on the Y
121       axis it's 0.25 further out at Y-0.25 to Y+0.75.  The stripe the corner
122       falls in can thus be biased by theta expressed as a fraction 0 to 1
123       around the plane.
124
125       An exact theta 0 to 1 would require an arctan, but approximations 0,
126       0.25, 0.5, 0.75 from the quadrants, or eighths of the plane by X>Y etc
127       diagonals.  As noted for the Theodorus spiral the over-estimate from
128       ignoring the angle is at worst R many points, which corresponds to a
129       full loop here.  Using the angle would reduce that to 1/4 or 1/8 etc of
130       a loop.
131

SEE ALSO

133       Math::PlanePath, Math::PlanePath::PyramidRows,
134       Math::PlanePath::ArchimedeanChords, Math::PlanePath::TheodorusSpiral,
135       Math::PlanePath::VogelFloret
136

HOME PAGE

138       <http://user42.tuxfamily.org/math-planepath/index.html>
139

LICENSE

141       Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
142       2020 Kevin Ryde
143
144       This file is part of Math-PlanePath.
145
146       Math-PlanePath is free software; you can redistribute it and/or modify
147       it under the terms of the GNU General Public License as published by
148       the Free Software Foundation; either version 3, or (at your option) any
149       later version.
150
151       Math-PlanePath is distributed in the hope that it will be useful, but
152       WITHOUT ANY WARRANTY; without even the implied warranty of
153       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
154       General Public License for more details.
155
156       You should have received a copy of the GNU General Public License along
157       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
158
159
160
161perl v5.32.1                      2021-01-27   Math::PlanePath::SacksSpiral(3)
Impressum