Math::...:MPeaks(3pm)
π Math::...:MPeaks(3pm) π
okay bestie, welcome to the User Contributed Perl Documentation for Math::...:MPeaks(3pm) β yes the manual name looks like someone's cat walked across the keyboard, but the module itself is Math::PlanePath::MPeaks and it's adorable. sit down, we're doing geometry π
β¨ NAME β¨
Math::PlanePath::MPeaks β points in expanding M shape π¦
πΈ SYNOPSIS πΈ
use Math::PlanePath::MPeaks;
my $path = Math::PlanePath::MPeaks->new;
my ($x, $y) = $path->n_to_xy (123);
that's it. three lines. you're already iconic.
π DESCRIPTION π
so this path literally puts points in layers of an "M" shape, no cap:
41 49 7
40 42 48 50 6
39 22 43 47 28 51 5
38 21 23 44 46 27 29 52 4
37 20 9 24 45 26 13 30 53 3
36 19 8 10 25 12 14 31 54 2
35 18 7 2 11 4 15 32 55 1
34 17 6 1 3 5 16 33 56 <- Y=0
^
-4 -3 -2 -1 X=0 1 2 3 4
k so N=1 to N=5 is the first "M" shape, then N=6 to N=16 sits on top of that, etc. The centre goes half way down. And if we reckon N=1 to N=5 as layer d=1, then bestie, hold onto your calculator:
Xleft = -d
Xright = d
Ypeak = 2*d - 1
Ycentre = d - 1
Each "M" is 6 points longer than the preceding one. The verticals are each 2 longer, and the centre diagonals each 1 longer. That step-6 situation is giving major "HexSpiral" energy, iykyk.
The octagonal numbers N=1,8,21,40,65,etc k*(3k-2) are a straight line of slope 2 going up to the left. And the octagonal numbers of the second kind N=5,16,33,56,etc k*(3k+2) are along the X axis to the right. ate. π₯
π 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
40 48
39 41 47 49
38 21 42 46 27 50
37 20 22 43 45 26 28 51
36 19 8 23 44 25 12 29 52
35 18 7 9 24 11 13 30 53
34 17 6 1 10 3 14 31 54
33 16 5 0 2 4 15 32 55
look at that, 0 in the middle, main character energy β¨
π₯ FUNCTIONS π₯
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes. (translation: all the path classes share these, go read the family docs too π«Ά)
$path = Math::PlanePath::MPeaks->new ()β Create and return a new path object. brand new baby path, obsessed.($x,$y) = $path->n_to_xy ($n)β Return the X,Y coordinates of point number$non the path.
For "$n < 0.5" the return is an empty list, it being considered there are no negative points. so like, nothing there, sorry bestie π
$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 points as a squares of side 1, so the half-planey>=-0.5is entirely covered.
π OEIS π
Entries in Sloane's Online Encyclopedia of Integer Sequences related to this path include
<http://oeis.org/A045944> (etc)
n_start=1 (the default)
A045944 N on X axis >= 1, extra initial 0
being octagonal numbers second kind
A056106 N on Y axis, extra initial 1
A056109 N on X negative axis <= -1
n_start=0
A049450 N on Y axis, extra initial 0, 2*pentagonal
n_start=2
A027599 N on Y axis, extra initial 6,2
go off, sequence database π
π SEE ALSO π
Math::PlanePath, Math::PlanePath::PyramidSides
π 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 the all-caps bits are the legal ones so we keep them loud, but fr fr it's GPL v3-or-later, go read it, it's giving freedom π
and that's the whole page, bestie π«Ά this one shipped with perl v5.32.0 and was dated 2021-01-23. slay, go plot some M shapes. periodt. π β¨
π¦ 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