Math::...Spiral(3pm)

πŸ“¦
version 129 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Math::...Spiral β€” the pyramid spiral page bestie πŸ’–

okay so real quick, the manual name for this whole vibe is Math::...Spiral (3pm, the perl manpage kind), and today's main character is Math::PlanePath::PyramidSpiral. let's get into it 🫢


✨ NAME ✨

Math::PlanePath::PyramidSpiral β€” integer points drawn around a pyramid πŸ”οΈβœ¨


🌸 SYNOPSIS 🌸

use Math::PlanePath::PyramidSpiral;
my $path = Math::PlanePath::PyramidSpiral->new;
my ($x, $y) = $path->n_to_xy (123);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this path literally makes a pyramid shaped spiral and it's giving geometry queen, no cap:

                         31                          3
                        /  \
                      32 13 30                       2
                     /  /  \  \
                   33 14  3 12 29                    1
                  /  /  /  \  \  \
                34 15  4  1--2 11 28 ...         <- Y=0
               /  /  /           \  \  \
             35 16  5--6--7--8--9-10 27 52          -1
            /  /                       \  \
          36 17-18-19-20-21-22-23-24-25-26 51       -2
         /                                   \
       37-38-39-40-41-42-43-44-45-46-47-48-49-50    -3

                          ^
       -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7

the perfect squares 1,4,9,16 fall one before the bottom left corner of each loop, and the pronic numbers 2,6,12,20,30,etc are the vertical upwards from X=1,Y=0. iconic behavior honestly πŸŽ€

πŸ”² Square Spiral πŸ”²

this spiral goes around at the same rate as the "SquareSpiral". it's as if two corners are cut off (like the "DiamondSpiral") and two others extended (like the "OctagramSpiral"). the net effect is the same looping rate but the points pushed around a bit. lowkey chaotic, highkey elegant πŸ’…

taking points up to a perfect square shows the similarity. the two triangular cut-off corners marked by "."s are matched by the two triangular extensions. periodt:

               +--------------------+   7x7 square
               | .  .  . 31  .  .  .|
               | .  . 32 13 30  .  .|
               | . 33 14  3 12 29  .|
               |34 15  4  1  2 11 28|
             35|16  5  6  7  8  9 10|27
          36 17|18 19 20 21 22 23 24|25 26
       37 38 39|40 41 42 43 44 45 46|47 48 49
               +--------------------+

πŸ”’ N Start πŸ”’

the default is to number points starting N=1 as shown above. an optional "n_start" can give a different start, with the same shape etc. for example to start at 0:

                   12         n_start => 0
                  /  \
                13  2 11
               /  /  \  \
             14  3  0--1 10
            /  /           \
          15  4--5--6--7--8--9
         /
       16-17-18-19-20-21-22-...

🧚 FUNCTIONS 🧚

see "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes. (iykyk)

  • $path = Math::PlanePath::PyramidSpiral->new ()
  • $path = Math::PlanePath::PyramidSpiral->new (n_start => $n)

create and return a new pyramid spiral object. brand new baby spiral, obsessed 🍼✨

  • $n = $path->xy_to_n ($x,$y)

return the point number for coordinates "$x,$y". $x and $y are each rounded to the nearest integer, which has the effect of treating each N in the path as centred in a square of side 1, so the entire plane is covered. every square inch accounted for, slay 🌈


πŸ‘‘ OEIS πŸ‘‘

this path is in Sloane's Online Encyclopedia of Integer Sequences as

<http://oeis.org/A053615> (etc)

n_start=1 (the default):

A053615    abs(X), distance to next pronic, but starts n=0
A054552    N on X axis, 4n^2 - 3n + 1
A033951    N on South-East diagonal, 4n^2 + 3n + 1

A214250    sum N of eight surrounding cells

A217013    permutation N of points in SquareSpiral order
             rotated +90 degrees
A217294    inverse

in the two permutations the pyramid spiral is conceived as starting to the left and the square spiral starting upwards. the paths here start in the same direction (both to the right), hence rotate 90 to adjust the orientation. math girlies rotate, we don't fold πŸ’…

n_start=0:

A329116    X coordinate
A329972    Y coordinate
A053615    abs(X)
A339265    dX-dY increments (runs +1,-1)
A001107    N on X axis, decagonal numbers
A002939    N on Y axis
A033991    N on X negative axis
A002943    N on Y negative axis
A007742    N on diagonal South-West
A033954    N on diagonal South-East, decagonal second kind

n_start=2:

A185669    N on diagonal South-East

πŸ’œ SEE ALSO πŸ’œ

Math::PlanePath, Math::PlanePath::SquareSpiral, Math::PlanePath::PyramidRows, Math::PlanePath::TriangleSpiral, Math::PlanePath::TriangleSpiralSkewed


🏠 HOME PAGE 🏠

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


πŸ“œ LICENSE πŸ“œ

Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Kevin Ryde

this file is part of Math-PlanePath.

Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-PlanePath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU General Public License for more details. (fr fr, read the fine print bestie πŸ™ˆ)

you should have received a copy of the GNU General Public License along with Math-PlanePath. if not, see <http://www.gnu.org/licenses/>.


okay that's the whole page, we ate and left no crumbs πŸ“βœ¨ this was perl v5.32.0, dated 2021-01-23, from the Math::...Spiral(3pm) era β€” mwah, bye bestie πŸ’–πŸ¦‹