Math::...h::Rows(3pm)

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

πŸ’– Math::...h::Rows β€” points in fixed-width rows πŸ’–

okay bestie, welcome to Math::PlanePath::Rows, straight outta the User Contributed Perl Documentation ✨ this one is genuinely one of the chillest path classes in the whole Math-PlanePath universe, and by the end of this page you're gonna be obsessed with it, no cap 🫢


✨ SYNOPSIS ✨

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

🌸 DESCRIPTION 🌸

so the whole vibe here is: it's rows of a given fixed width. that's it. that's the path. width=7 looks like this, and honestly it's giving grid energy πŸ‘‘

    width => 7

      3  |  22  23  24 ...
      2  |  15  16  17  18  19  20  21
      1  |   8   9  10  11  12  13  14
    Y=0  |   1   2   3   4   5   6   7
          -------------------------------
           X=0   1   2   3   4   5   6

πŸ’… N Start

by default it numbers points starting at N=1, just like the diagram up there ⬆️ but if you want, an optional "n_start" can give you a different start while keeping the exact same shape. for example, to start at 0:

    n_start => 0, width => 7

      3  |  21  22  23  24 ...
      2  |  14  15  16  17  18  19  20
      1  |   7   8   9  10  11  12  13
    Y=0  |   0   1   2   3   4   5   6
          -------------------------------
           X=0   1   2   3   4   5   6

the only effect is to push the N values around by a constant amount, fr fr. it might help match coordinates with something else that's zero-based 🌈


✨ FUNCTIONS ✨

see "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes πŸ’œ

  • $path = Math::PlanePath::Rows->new (width => $w)
  • $path = Math::PlanePath::Rows->new (width => $w, n_start => $n)

create and return a new path object πŸŽ€ a "width" parameter must be supplied, okay? like, non-negotiable, bestie.

  • ($x,$y) = $path->n_to_xy ($n)

return the X,Y coordinates of point number $n in the path.

  • $n = $path->xy_to_n ($x,$y)

return the point number for coordinates "$x,$y".

$x and $y are rounded to the nearest integers, which has the effect of treating each point in the path as a square of side 1, so a column -0.5 <= x < width+0.5 and y>=-0.5 is covered. cute, right? πŸ¦‹

  • ($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)

the returned range is exact, meaning $n_lo and $n_hi are the smallest and biggest in the rectangle πŸ’―


🌈 SEE ALSO 🌈

Math::PlanePath, Math::PlanePath::Columns


πŸ‘‘ 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/>.


and that's the whole page bestie!! πŸ₯³ this was Math::...h::Rows(3pm), generated by perl v5.32.0 on 2021-01-23 β€” go read it, then go build some rows, you absolute icon πŸ’…βœ¨