Math::...mSpiral(3pm)
π Math::PlanePath::OctagramSpiral π«
okay bestie, gather round, because we're about to talk about the User Contributed Perl Documentation page for Math::PlanePath::OctagramSpiral and honestly? it's giving star-shaped main character energy β¨
π NAME π
Math::PlanePath::OctagramSpiral β integer points drawn around an octagram π
like. it's a path. of integers. shaped like an 8-pointed star. no cap. π
β¨ SYNOPSIS β¨
use Math::PlanePath::OctagramSpiral;
my $path = Math::PlanePath::OctagramSpiral->new;
my ($x, $y) = $path->n_to_xy (123);
that's it. that's the whole vibe check. π¦
π DESCRIPTION π
so this path makes a spiral around an octagram (that's an 8-pointed star, iykyk) β
29 25 4
| \ / |
30 28 26 24 ...56-55 3
| \ / | /
33-32-31 7 27 5 23-22-21 54 2
\ |\ / | / /
34 9- 8 6 4- 3 20 53 1
\ \ / / /
35 10 1--2 19 52 <- Y=0
/ / \ \
36 11-12 14 16-17-18 51 -1
/ |/ \ | \
37-38-39 13 43 15 47-48-49-50 -2
| / \ |
40 42 44 46 -3
|/ \ |
41 45 -4
^
-4 -3 -2 -1 X=0 1 2 3 4 5 ...
each loop is 16 longer than the previous one. obsessed. π₯ and the 18-gonal numbers 18,51,100,etc fall on the horizontal at Y=-1 β they're just chilling there, periodt.
the inner corners like 23, 31, 39, 47 are lowkey similar to the "SquareSpiral" path, BUT (and this is the plot twist) instead of going directly between them, the octagram takes a detour out to make the points of the star. those excursions make each loop 8 longer (that's 1 per excursion, bestie), hence a step of 16 here as compared to 8 for the "SquareSpiral". the math is mathing π
πΈ 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,
n_start => 0
28 24
29 27 25 23 ... 55 54
32 31 30 6 26 4 22 21 20 53
33 8 7 5 3 2 19 52
34 9 0 1 18 51
35 10 11 13 15 16 17 50
36 37 38 12 42 14 46 47 48 49
39 41 43 45
40 44
look at her go π§
π«Ά FUNCTIONS π«Ά
see "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes. (yes bestie, shared lore π)
"$path = Math::PlanePath::OctagramSpiral->new ()"β create and return a new octagram spiral object. a fresh little star, just for you π"($x,$y) = $path->n_to_xy ($n)"β return the X,Y coordinates of point number$non the path.
for "$n < 1" the return is an empty list, it being considered the path starts at 1. so like, nothing before 1. the path simply does not know her π
"$n = $path->xy_to_n ($x,$y)"β return the point number for coordinates"$x,$y".$xand$yare 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. the whole plane!! covered!! slay π
π FORMULAS π
β X,Y to N β
the symmetry of the octagram can be used by rotating a given X,Y back to the first star excursion such as N=19 to N=23. so here's the rotation recipe, step by step:
- if
Yis negative then rotate back by 180 degrees, - then if
Xis negative rotate back by 90, - and if
Y>=Xthen by a further 45 degrees.
each such rotation, if needed, is counted as a multiple of the side-length to be added to the final N. for example at N=19 the side length is 2. rotating by 180 degrees is 8 side lengths, by 90 degrees 4 sides, and by 45 degrees is 2 sides. β¨ geometry icon behaviour β¨
π₯ OEIS π₯
entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include
<http://oeis.org/A125201> (etc)
n_start=1 (the default)
A125201 N on X axis, from X=1 onwards, 18-gonals + 1
A194268 N on diagonal South-East
n_start=0
A051870 N on X axis, 18-gonal numbers
A139273 N on Y axis
A139275 N on X negative axis
A139277 N on Y negative axis
A139272 N on diagonal X=Y
A139274 N on diagonal North-West
A139276 N on diagonal South-West
A139278 N on diagonal South-East, second 18-gonals
so many sequence numbers, so little time π
π¦ SEE ALSO π¦
- Math::PlanePath
- Math::PlanePath::SquareSpiral
- Math::PlanePath::PyramidSpiral
the whole friend group, honestly π«Ά
πΈ 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/>.
okay real talk for one second β that warranty bit is not a joke, bestie. it genuinely ships with no warranty. respect the license π
and that's the whole page!! perl v5.32.0, dated 2021-01-23 β this one's from the User Contributed Perl Documentation corner of the internet, and it ate. no crumbs. bye bestie, go draw a star βπ
π¦ where this page comes from
- debian bookworm: libmath-planepath-perl 129-1 Β· GPL-3.0-or-later
- debian trixie: libmath-planepath-perl 129-1 Β· GPL-3.0-or-later
- ubuntu jammy: libmath-planepath-perl 129-1 Β· GPL-3.0-or-later
- ubuntu noble: libmath-planepath-perl 129-1 Β· GPL-3.0-or-later
- ubuntu resolute: libmath-planepath-perl 129-1 Β· GPL-3.0-or-later
- ubuntu stonking: libmath-planepath-perl 129-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms