Math::...lSkewed(3pm)

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

πŸ’– NAME πŸ’–

Math::PlanePath::HeptSpiralSkewed β€” integer points around a skewed seven sided spiral ✨

okay bestie so the manual name is Math::...lSkewed(3pm) (it's giving truncated-perl-header energy, the full thing is Math::PlanePath::HeptSpiralSkewed(3pm)), and this page is literally all about making a seven-sided spiral out of integer points πŸŒ€


🌸 SYNOPSIS 🌸

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

✨ DESCRIPTION ✨

This path makes a seven-sided spiral by cutting one corner of a square. no cap, that's the whole vibe πŸ’…

           31-30-29-28                       3
            |         \
           32 14-13-12 27                    2
            |  |      \  \
           33 15  4--3 11 26                 1
            |  |  |   \  \  \
           34 16  5  1--2 10 25         <- Y=0
            |  |  |        |  |
           35 17  6--7--8--9 24             -1
            |  |              |
           36 18-19-20-21-22-23             -2
            |
           37-38-39-40-41-...               -3

                     ^
           -3 -2 -1 X=0 1  2  3

The path is as if around a heptagon, with the left and bottom here as two sides of the heptagon straightened out, and the flat top here skewed across to fit a square grid. πŸ¦‹ iconic honestly

πŸŽ€ N Start πŸŽ€

The default is to number points starting N=1 as shown above. An optional n_start can give a different start, in the same pattern. For example to start at 0, 🌈

           30 29 28 27              n_start => 0
           31 13 12 11 26
           32 14  3  2 10 25
           33 15  4  0  1  9 24
           34 16  5  6  7  8 23
           35 17 18 19 20 21 22
           36 37 38 39 40 ...

πŸ’œ FUNCTIONS πŸ’œ

See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes. (shared lore iykyk 🫢)

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

Create and return a new path object. boom, new path, main character energy πŸ‘‘

  • $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. literally the whole plane bestie, no gaps 🌈


🧚 FORMULAS 🧚

⭐ N to X,Y ⭐

It's convenient to work in terms of Nstart=0 and to take each loop as beginning on the South-West diagonal, πŸ’«

                     top length = d

                     30-29-28-27
                      |         \
                     31          26    diagonal length = d
          left        |            \
          length     32             25
           = 2*d      |               \
                     33        0       24
                      |                 |    right
                     34     .          23    length = d-1
                      |                 |
                     35 17-18-19-20-21-22
                      |
                      .    bottom length = 2*d-1

The SW diagonal is N=0,5,17,36,etc which is

N = (7d-11)*d/2 + 2           # starting d=1 first loop

This can be inverted to get d from N

d = floor( (sqrt(56*N+9)+11)/14 )

The side lengths are as shown above. The first loop is d=1 and for it the "right" vertical length is zero, so no such side on that first loop 0 <= N < 5. 😭 the right side just doesn't exist yet, she's growing


πŸ“ OEIS πŸ“

Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include

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

n_start=1
  A140065    N on Y axis

n_start=0
  A001106    N on X axis, 9-gonal numbers
  A218471    N on Y axis
  A022265    N on X negative axis
  A179986    N on Y negative axis, second 9-gonals
  A195023    N on X=Y diagonal
  A022264    N on North-West diagonal
  A186029    N on South-West diagonal
  A024966    N on South-East diagonal

slay, she's in the encyclopedia πŸ’…πŸ“š


πŸ”₯ SEE ALSO πŸ”₯

Math::PlanePath, Math::PlanePath::SquareSpiral, Math::PlanePath::PentSpiralSkewed, Math::PlanePath::HexSpiralSkewed

(the whole spiral girlie squad 🫢)


🌈 HOME PAGE 🌈

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


πŸ‘‘ LICENSE πŸ‘‘

Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 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.

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

bestie the "WITHOUT ANY WARRANTY" is not a drill, no implied merchantability or fitness for a particular purpose, fr fr 😭

and that's the whole page!! this cutie was perl v5.32.0, dated 2021-01-23, and the manual name is Math::...lSkewed(3pm) β€” go make some heptagons bestie, ily πŸ’–βœ¨