Math::...idpoint(3pm)

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

πŸ’– Math::PlanePath::AlternatePaperMidpoint πŸ’–

okay bestie, so this is one of those Perl module pages β€” from the User Contributed Perl Documentation collection, no less β€” and it's called Math::PlanePath::AlternatePaperMidpoint. Yes, the name is a whole mouthful, we're gonna call it the midpoints curve from here on, mmkay? ✨


🌸 NAME 🌸

Math::PlanePath::AlternatePaperMidpoint β€” the midpoints of the alternate paper folding curve, like, literally the points in between πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

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

that's it, that's the whole vibe check πŸ’…


✨ DESCRIPTION ✨

So here's the tea: this path is the midpoints of each alternate paper folding curve β€” that's Math::PlanePath::AlternatePaper for the ones taking notes πŸ“

     8  |                        64-65-...
        |                         |
     7  |                        63
        |                         |
     6  |                  20-21 62
        |                   |  |  |
     5  |                  19 22 61-60-59
        |                   |  |        |
     4  |            16-17-18 23 56-57-58
        |             |        |  |
     3  |            15 26-25-24 55 50-49-48-47
        |             |  |        |  |        |
     2  |       4--5 14 27-28-29 54 51 36-37 46
        |       |  |  |        |  |  |  |  |  |
     1  |       3  6 13-12-11 30 53-52 35 38 45-44-43
        |       |  |        |  |        |  |        |
    Y=0 | 0--1--2  7--8--9-10 31-32-33-34 39-40-41-42
        +----------------------------------------------
        X=0  1  2  3  4  5  6  7  8  9 10 11 12 13 14

The AlternatePaper curve starts out looking like this, and the midpoints get numbered starting from 0:

                  |
                  9
                  |
             --8--
            |     |
            7     |
            |     |
       --2-- --6--
      |     |     |
      1     3     5
      |     |     |
*--0--       --4--

These midpoints land on fractions like X=0.5,Y=0, X=1,Y=0.5, etc. β€” cute little half-steps πŸ“ But for this AlternatePaperMidpoint, they get turned 45 degrees and mirrored, so the 0,1,2 upward diagonal becomes horizontal along the X axis, and the 2,3,4 downward diagonal becomes a vertical at X=2, stretching all the way to X=2,Y=2 at N=4. Slay 🫢

The midpoints are all distinct X,Y positions, and the reason is honestly so valid: the alternate paper curve traverses each edge only once. no repeats, no drama πŸ’…

The curve is self-similar in 2^level sections because of its unfolding. You can literally see it in the midpoints β€” for example, N=0 to N=16 above is the same shape as N=16 to N=32, except the latter is rotated +90 degrees and numbered in reverse. iconic behaviour, honestly ✨

🌈 Arms 🌈

The midpoints fill an eighth of the plane, and eight copies can mesh together perfectly when mirrored and rotated by 90, 180 and 270 degrees. The arms parameter lets you choose 1 to 8 curve arms successively advancing. obsessed 😌

For example, arms => 8 begins like this. N=0,8,16,24,etc is the first arm β€” same as the plain curve above. N=1,9,17,25 is the second, N=2,10,18,26 the third, etc.

                      90-82 81-89                       7
   arms => 8          |  |  |  |
                    ... 74 73 ...                      6
                         |  |
                        66 65                          5
                         |  |
            43-35 42-50-58 57-49-41                    4
             |  |  |              |
   91-..    51 27 34-26-18 17-25-33                    3
    |        |  |        |  |
   83-75-67-59 19-11--3 10  9 32-40                    2
                         |  |  |  |
   84-76-68-60 20-12--4  2  1 24 48    ..-88           1
    |        |  |              |  |        |
   92-..    52 28  5  6  0--8-16 56-64-72-80      <- Y=0
             |  |  |  |
            44-36 13 14  7-15-23 63-71-79-87          -1
                   |  |        |  |        |
            37-29-21 22-30-38 31 55    ..-95          -2
             |              |  |  |
            45-53-61 62-54-46 39-47                   -3
                   |  |
                  69 70                               -4
                   |  |
              ... 77 78 ...                           -5
                |  |  |  |
               93-85 86-94                            -6

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

With eight arms like this, every X,Y point is visited exactly once β€” because the 8-arm AlternatePaper traverses every edge exactly once (see "Arms" in Math::PlanePath::AlternatePaper). no cap πŸ”₯

heads up bestie: the arm numbering does not correspond to the AlternatePaper, because of the rotate and reflect of the first arm. It ends up that arms 0 and 1 of the AlternatePaper correspond to arms 7 and 0 of the midpoints here β€” those two being a pair going horizontally, matching a pair in the AlternatePaper that goes diagonally into a quadrant. iykyk πŸ’€

πŸ’œ FUNCTIONS πŸ’œ

For behaviour common to all path classes, go see "FUNCTIONS" in Math::PlanePath πŸ“š

  • $path = Math::PlanePath::AlternatePaperMidpoint->new () β€” create and return a brand new path object. fresh out the box 🎁
  • ($x,$y) = $path->n_to_xy ($n) β€” gives you back the X,Y coordinates of point number $n on the path. Points begin at 0, and if $n < 0 then the return is an empty list. (yeah, empty list, it said what it said 🫠)

Fractional positions give an X,Y position along a straight line between the integer positions β€” so like, halfway vibes πŸ¦‹

  • $n = $path->n_start() β€” returns 0, the first N in the path. the beginning of the story ✨

🧚 Level Methods 🧚

  • ($n_lo, $n_hi) = $path->level_to_n_range($level) β€” returns (0, 2**$level - 1), or for multiple arms returns (0, $arms * (2**$level - 1)*$arms). This is the same as the DragonMidpoint. twinsies πŸ’…

πŸ‘‘ OEIS πŸ‘‘

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

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

A334576     X coordinate
A334577     Y coordinate
A016116     X/2 at N=2^k, being X/2=2^floor(k/2)

go look them up bestie, they're lowkey fascinating πŸ“


🌟 SEE ALSO 🌟

  • Math::PlanePath, Math::PlanePath::AlternatePaper
  • Math::PlanePath::DragonMidpoint, Math::PlanePath::R5DragonMidpoint, Math::PlanePath::TerdragonMidpoint

the whole midpoint friend group honestly 🫢


πŸŽ€ HOME PAGE πŸŽ€

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


πŸ’– LICENSE πŸ’–

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

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/>.

ok that last part is serious business fr fr β€” no warranty, read the license, respect the license πŸ’…

and that's the whole page, bestie!! this one's Math::...idpoint(3pm) from perl v5.32.0, dated 2021-01-23 β€” so it's a little vintage but it still eats πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ‘‘πŸŒˆβ­