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

FUNCTIONS

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

FORMULAS

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

SEE ALSO

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

HOME PAGE

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

LICENSE

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