Math::...icCurve(3pm)

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

πŸ‘‘ Math::...icCurve(3pm) β€” like, the whole vibe

okay bestie, sit down, hydrate, because we're about to talk about Math::PlanePath::QuadricCurve πŸ’– and yes it lives in the User Contributed Perl Documentation, which is exactly where you'd expect to find a little eight-segment zig-zag icon doing its thing. no cap.

✨ NAME ✨

Math::PlanePath::QuadricCurve β€” eight segment zig-zag. that's it, that's the whole name, she's simple, she's iconic πŸŽ€

🌸 SYNOPSIS 🌸

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

three lines. three. lines. and she ate πŸ”₯

πŸ¦‹ DESCRIPTION πŸ¦‹

so this is a self-similar zig-zag of eight segments, and honestly? the way she draws herself is giving main character energy:

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

the base figure is the initial N=0 to N=8, and look at her:

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

then she repeats β€” turned to follow edge directions β€” so N=8 to N=16 is the same shape going upwards, then N=16 to N=24 across, N=24 to N=32 downwards, etc. she's just doing it again and again and it WORKS every time πŸ’…

the result is the base at ever greater scale extending to the right, with wiggly lines making up the segments. and the wiggles don't overlap. not once. immaculate behaviour fr fr.

⚠️ tea time: the name "QuadricCurve" here is a slight mistake. Mandelbrot ("Fractal Geometry of Nature" 1982 page 50) calls any islands initiated from a square "quadric", and only one of those is with sides by this eight segment expansion. this curve expansion also appears (unnamed) in Mandelbrot's "How Long is the Coast of Britain", 1967. so like... the name is a little off but we're not changing it, periodt.

πŸ“ Level Ranges

a given replication extends to:

Nlevel = 8^level
X = 4^level
Y = 0

Ymax = 4^0 + 4^1 + ... + 4^level   # 11...11 in base 4
     = (4^(level+1) - 1) / 3
Ymin = - Ymax

not me getting emotional over 11...11 in base 4 😭 she's so tidy.

πŸ”„ Turn

the sequence of turns made by the curve is straightforward β€” no drama, no plot twists (well, except the literal turns). in the base 8 (octal) representation of N, the lowest non-zero digit gives the turn:

low digit   turn (degrees)
---------   --------------
   1            +90  L
   2            -90  R
   3            -90  R
   4              0
   5            +90  L
   6            +90  L
   7            -90  R

when the least significant digit is non-zero it determines the turn, to make the base N=0 to N=8 shape. when the low digit is zero it's instead the next level up β€” the N=0,8,16,24,etc shape β€” which is in control, applying a turn for the subsequent base part. so for example at N=16 = 20 octal, 20 is a turn -90 degrees. iykyk 🧚

πŸ’– FUNCTIONS πŸ’–

see "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes. (she shares, she's generous, we love a collaborative queen 🫢)

  • $path = Math::PlanePath::QuadricCurve->new () β€” create and return a new path object. that's it. new path, new me, new era ✨
  • ($x,$y) = $path->n_to_xy ($n) β€” return 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. so don't come at her with negative numbers and expect coordinates, bestie, you'll get nothing back πŸ’€

πŸŽ€ Level Methods

  • ($n_lo, $n_hi) = $path->level_to_n_range($level) β€” return (0, 8**$level). clean. precise. gorgeous.

πŸ” OEIS

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

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

A332246   X coordinate
A332247   Y coordinate
A133851   Y at N=2^k, being successive powers 2^j at k=1mod4

she's published, she's in the encyclopedia, she's got citations, we're obsessed πŸ˜­πŸ‘‘

πŸ‘€ SEE ALSO

  • Math::PlanePath
  • Math::PlanePath::QuadricIslands
  • Math::PlanePath::KochCurve

and also Math::Fractal::Curve β€” its examples/generator4.pl is this curve. cute crossover moment fr.

🏠 HOME PAGE

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

πŸ“œ LICENSE

Copyright 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 that's the whole page, you read all of it, I'm so proud of you πŸ₯ΉπŸ’œ this was perl v5.32.0, dated 2021-01-23, and it's giving Math::...icCurve(3pm) energy forever. mwah πŸ’…πŸŽ€