Math::PlanePath(3pm)
π¦ Math::PlanePath(3pm) β points on a path through the 2-D plane π
User Contributed Perl Documentation, bestie. This one is Math::PlanePath, and it's giving base-class energy for a whole little universe of plane paths. β¨
πΈ NAME πΈ
Math::PlanePath -- points on a path through the 2-D plane.
β¨ SYNOPSIS β¨
use Math::PlanePath;
# only a base class, see the subclasses for actual operation
π DESCRIPTION π
Okay so, this is a base class for some mathematical paths which map an integer position $n to and from coordinates "$x,$y" in the 2D plane. Literally the glow-up from one number to a coordinate pair. π«
The current classes include the following. The intention is that any Math::PlanePath::Something is a PlanePath, and supporting base classes or related things are further down like Math::PlanePath::Base::Xyzzy.
SquareSpiralβ four-sided spiralPyramidSpiralβ square base pyramidTriangleSpiralβ equilateral triangle spiralTriangleSpiralSkewedβ equilateral skewed for compactnessDiamondSpiralβ four-sided spiral, looping fasterPentSpiralβ five-sided spiralPentSpiralSkewedβ five-sided spiral, compactHexSpiralβ six-sided spiralHexSpiralSkewedβ six-sided spiral skewed for compactnessHeptSpiralSkewedβ seven-sided spiral, compactAnvilSpiralβ anvil shapeOctagramSpiralβ eight pointed starKnightSpiralβ an infinite knight's tourCretanLabyrinthβ 7-circuit extended infinitelySquareArmsβ four-arm square spiralDiamondArmsβ four-arm diamond spiralAztecDiamondRingsβ four-sided ringsHexArmsβ six-arm hexagonal spiralGreekKeySpiralβ square spiral with Greek key motifMPeaksβ "M" shape layersSacksSpiralβ quadratic on an Archimedean spiralVogelFloretβ seeds in a sunflowerTheodorusSpiralβ unit steps at right anglesArchimedeanChordsβ unit chords on an Archimedean spiralMultipleRingsβ concentric circlesPixelRingsβ concentric rings of midpoint pixelsFilledRingsβ concentric rings of pixelsHypotβ points by distanceHypotOctantβ first octant points by distanceTriangularHypotβ points by triangular distancePythagoreanTreeβ X^2+Y^2=Z^2 by treesPeanoCurveβ 3x3 self-similar quadrantPeanoDiagonalsβ across unit squaresWunderlichSerpentineβ transpose parts of PeanoCurveHilbertCurveβ 2x2 self-similar quadrantHilbertSidesβ along sides of unit squaresHilbertSpiralβ 2x2 self-similar whole-planeZOrderCurveβ replicating Z shapesGrayCodeβ Gray code splitsWunderlichMeanderβ 3x3 "R" pattern quadrantBetaOmegaβ 2x2 self-similar half-planeAR2W2Curveβ 2x2 self-similar of four partsKochelCurveβ 3x3 self-similar of two partsDekkingCurveβ 5x5 self-similar, edgesDekkingCentresβ 5x5 self-similar, centresCincoCurveβ 5x5 self-similarImaginaryBaseβ replicate in four directionsImaginaryHalfβ half-plane replicate three directionsCubicBaseβ replicate in three directionsSquareReplicateβ 3x3 replicating squaresCornerReplicateβ 2x2 replicating "U"LTilingβ self-similar L shapesDigitGroupsβ digits grouped by zerosFibonacciWordFractalβ turns by Fibonacci word bitsFlowsnakeβ self-similar hexagonal tile traversalFlowsnakeCentresβ likewise but centres of hexagonsGosperReplicateβ self-similar hexagonal tilingGosperIslandsβ concentric island ringsGosperSideβ single side or radialQuintetCurveβ self-similar "+" traversalQuintetCentresβ likewise but centres of squaresQuintetReplicateβ self-similar "+" tilingDragonCurveβ paper foldingDragonRoundedβ paper folding rounded cornersDragonMidpointβ paper folding segment midpointsAlternatePaperβ alternating direction foldingAlternatePaperMidpointβ alternating direction folding, midpointsTerdragonCurveβ ternary dragonTerdragonRoundedβ ternary dragon rounded cornersTerdragonMidpointβ ternary dragon segment midpointsAlternateTerdragonβ alternate ternary dragonR5DragonCurveβ radix-5 dragon curveR5DragonMidpointβ radix-5 dragon curve midpointsCCurveβ "C" curveComplexPlusβ base i+realpartComplexMinusβ base i-realpart, including twindragonComplexRevolvingβ revolving base i+1SierpinskiCurveβ self-similar right-trianglesSierpinskiCurveStairβ self-similar right-triangles, stair-stepHIndexingβ self-similar right-triangles, squared upKochCurveβ replicating triangular notchesKochPeaksβ two replicating notchesKochSnowflakesβ concentric notched 3-sided ringsKochSquareflakesβ concentric notched 4-sided ringsQuadricCurveβ eight segment zig-zagQuadricIslandsβ rings of those zig-zagsSierpinskiTriangleβ self-similar triangle by rowsSierpinskiArrowheadβ self-similar triangle connectedlySierpinskiArrowheadCentresβ likewise but centres of trianglesRowsβ fixed-width rowsColumnsβ fixed-height columnsDiagonalsβ diagonals between X and Y axesDiagonalsAlternatingβ diagonals Y to X and back againDiagonalsOctantβ diagonals between Y axis and X=Y centreStaircaseβ stairs down from the Y to X axesStaircaseAlternatingβ stairs Y to X and back againCornerβ expanding stripes around a cornerCornerAlternatingβ expanding up and down around a cornerPyramidRowsβ expanding stacked rows pyramidPyramidSidesβ along the sides of a 45-degree pyramidCellularRuleβ cellular automaton by rule numberCellularRule54β cellular automaton rows patternCellularRule57β cellular automaton (rule 99 mirror too)CellularRule190β cellular automaton (rule 246 mirror too)UlamWarburtonβ cellular automaton diamondsUlamWarburtonQuarterβ cellular automaton quarter-planeDiagonalRationalsβ rationals X/Y by diagonalsFactorRationalsβ rationals X/Y by prime factorizationGcdRationalsβ rationals X/Y by rows with GCD integerRationalsTreeβ rationals X/Y by treeFractionsTreeβ fractions 0<X/Y<1 by treeChanTreeβ rationals X/Y multi-child treeCfracDigitsβ continued fraction 0<X/Y<1 by digitsCoprimeColumnsβ coprime X,YDivisibleColumnsβ X divisible by YWythoffArrayβ Fibonacci recurrencesWythoffPreliminaryTrianglePowerArrayβ powers in rowsFileβ points from a disk file
And in the separate Math-PlanePath-Toothpick distribution
ToothpickTreeβ pattern of toothpicksToothpickReplicateβ same by replication rather than treeToothpickUpistβ toothpicks only growing upwardsToothpickSpiralβ toothpicks around the originLCornerTreeβ L-shape corner growthLCornerReplicateβ same by replication rather than treeOneOfEightHTreeβ H shapes replicated
The paths are object oriented to allow parameters, though many have none. See examples/numbers.pl in the Math-PlanePath sources for a sample printout of numbers from selected paths or all paths. So if you want the receipts, that's where they live. π§Ύ
π’ Number Types π’
The $n and "$x,$y" parameters can be either integers or floating point. The paths are meant to do something sensible with fractions but expect round-off for big floating point exponents. So, like, fractions are welcome, but don't come for big exponents and expect perfection. π
Floating point infinities (when available) give NaN or infinite returns of some kind (some unspecified kind as yet). n_to_xy() on negative infinity is an empty return the same as other negative $n. Bestie, the infinity behavior is still a little mystery. π
Floating point NaNs (when available) give NaN, infinite, or empty/undef returns, but again of some unspecified kind as yet. So NaN is giving chaos, lowkey. πͺοΈ
Most of the classes can operate on overloaded number types as inputs and give corresponding outputs.
Math::BigInt maybe perl 5.8 up for ** operator
Math::BigRat
Math::BigFloat
Number::Fraction 1.14 or higher for abs()
A few classes might truncate a bignum or a fraction to a float as yet. In general the intention is to make the calculations generic enough to act on any sensible number type. Recent enough versions of the bignum modules might be required, perhaps BigInt of Perl 5.8 or higher for ** exponentiation operator.
For reference, an undef input as $n, $x, $y, etc, is designed to provoke an uninitialized value warning when warnings are enabled. Perhaps that will change, but the warning at least prevents bad inputs going unnoticed. So yes, undef is not a vibe, it's a warning generator. π¨
π οΈ FUNCTIONS π οΈ
In the following Foo is one of the various subclasses, see the list above and under "SEE ALSO".
π§Έ Constructor π§Έ
$path = Math::PlanePath::Foo->new (key=>value, ...) Create and return a new path object. Optional key/value parameters may control aspects of the object.
π Coordinate Methods π
($x,$y) = $path->n_to_xy ($n) Return X,Y coordinates of point $n on the path. If there's no point $n then the return is an empty list. For example
my ($x,$y) = $path->n_to_xy (-123)
or next; # no negatives in $path
Paths start from $path->n_start() below, though some will give a position for N=0 or N=-0.5 too.
($dx,$dy) = $path->n_to_dxdy ($n) Return the change in X and Y going from point $n to point $n+1, or for paths with multiple arms from $n to $n+$arms_count (thus advancing one point along the arm of $n).
+ $n+1 == $next_x,$next_y
^
|
| $dx = $next_x - $x
+ $n == $x,$y $dy = $next_y - $y
$n can be fractional and in that case the dX,dY is from that fractional $n position to $n+1 (or $n+$arms).
frac $n+1 == $next_x,$next_y
v
integer *---+----
| /
| /
|/ $dx = $next_x - $x
frac + $n == $x,$y $dy = $next_y - $y
|
integer *
In both cases n_to_dxdy() is just the difference $dx=$next_x-$x, $dy=$next_y-$y. Right now, for most paths, it's literally just two n_to_xy() calls to get both points β but some paths can compute a dX,dY with a lil less work. Efficiency queen π
$rsquared = $path->n_to_radius ($n)$rsquared = $path->n_to_rsquared ($n)β hand over the radial distance R=sqrt(X^2+Y^2) of point$n, or the radius squared R^2=X^2+Y^2. No point$n? You getundef, bestie, sorry.
For a few paths these can be computed with less work than n_to_xy(). Like, the SacksSpiral is literally just R^2=N, and MultipleRings with its default step=6 gives an integer radius for integer $n while $x,$y are fractional (and therefore inexact). So sometimes the radius route is just cleaner β¨
$n = $path->xy_to_n ($x,$y)β give me the N point number sitting at coordinates$x,$y. Nothing there?undef.
my $n = $path->xy_to_n(20,20);
if (! defined $n) {
next; # nothing at this X,Y
}
$x and $y can be fractional, and the path classes will return an integer $n that contains $x,$y inside a unit square, circle, or whatever intended figure centred on that integer $n π―
For paths that completely fill the plane there's always an $n to hand back, but for the spread-out paths an $x,$y position might fall in between (no $n close enough) and give you undef.
@n_list = $path->xy_to_n_list ($x,$y)β hand over a list of N point numbers at coordinates$x,$y. Nothing there? Empty list, no drama.
my @n_list = $path->xy_to_n(20,20);
Most paths have just a single N for a given X,Y, but some β looking at you DragonCurve and TerdragonCurve π β have multiple N's, and this method returns all of them.
Currently all paths have a finite number of N at a given location. What happens for an infinite list is unspecified, if that ever even happened.
@n_list = $path->n_to_n_list ($n)β hand over a list of all N point numbers at the location of$n. This is equivalent toxy_to_n_list(n_to_xy($n)).
The list you get back includes $n itself. If there's no $n in the path you get an empty list back.
This one is so convenient for paths like DragonCurve or TerdragonCurve with double or triple visited points, where one N might have other N's chillin' at the exact same location π«Ά
$bool = $path->xy_is_visited ($x,$y)β true if$x,$yis visited. Equivalent to
defined($path->xy_to_n($x,$y))
Some paths cover the whole plane and for those xy_is_visited() is always true. For others it might be less work to test a point than to actually calculate its $n.
$n = $path->xyxy_to_n($x1,$y1, $x2,$y2)$n = $path->xyxy_to_n_either($x1,$y1, $x2,$y2)@n_list = $path->xyxy_to_n_list($x1,$y1, $x2,$y2)@n_list = $path->xyxy_to_n_list_either($x1,$y1, $x2,$y2)β hand over <$n> which goes from$x1,$y1to$x2,$y2. <$n> is at$x1,$y1and$n+1is at$x2,$y2, or for a multi-arm path$n+$arms, so it's a step along the same arm. No such $n?undef, bestie.
The either() forms allow <$n> in either direction β so $x1,$y1 to $x2,$y2, or the other way round $x2,$y2 to $x1,$y1.
The n_list() forms return a list of every $n going between $x1,$y1 and $x2,$y2. For example in Math::PlanePath::CCurve some segments get traversed twice, once in each direction π
The possible N values at each X,Y are determined the same way as for xy_to_n().
($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)β hand over a range of N values covering the rectangle with corners at $x1,$y1 and $x2,$y2. The range is inclusive. Like:
my ($n_lo, $n_hi) = $path->rect_to_n_range (-5,-5, 5,5);
foreach my $n ($n_lo .. $n_hi) {
my ($x, $y) = $path->n_to_xy($n) or next;
print "$n $x,$y";
}
The return might be an over-estimate of the N range required to cover the rectangle. And even when the range is exact, the nature of the path might mean tons of points between $n_lo and $n_hi are actually outside the rectangle. But the range is at least a lower and upper bound on the N values occurring in the rectangle. Classes that guarantee an exact lo/hi will say so in their docs, no cap π’
$n_hi is usually no more than an extra partial row, revolution, or self-similar level. $n_lo might be merely the starting $path->n_start(), which is fine if the origin is inside the rectangle you want β but away from the origin it could actually start higher.
$x1,$y1 and $x2,$y2 can be fractional. If they partly overlap some N figures then those N's are included in the return.
If there are no points in the rectangle then the return can be a "crossed" range like $n_lo=1, $n_hi=0 (which makes a foreach do zero loops, iconic behaviour honestly). But rect_to_n_range() may not always notice there are no points in the rectangle and might instead hand back an over-estimate.
π Descriptive Methods π
$n = $path->n_start()β hand over the first N in the path. The start is usually either 0 or 1, depending on what's most natural for the path. Some paths have ann_startparameter to control the numbering.
Some classes have secret dubious undocumented support for N values below this start (zero or negative), but n_start() is the intended starting point. The intended one. π
$f = $path->n_frac_discontinuity()β hand over the fraction of N at which there may be discontinuities in the path. For example if there's a jump in the coordinates between N=7.4999 and N=7.5 then the returned $f is 0.5. Or $f is 0 if there's a discontinuity between 6.999 and 7.0.
If there are no discontinuities in the path then the return is undef. That means, for example, fractions between N=7 to N=8 give smooth continuous X,Y values (of some kind).
This is mainly of interest for drawing line segments between N points. If there are discontinuities then the idea is to draw from, say, N=7.0 to N=7.499 and then another line from N=7.5 to N=8 βοΈ
$arms = $path->arms_count()β hand over the number of arms in a "multi-arm" path.
For example in SquareArms this is 4, and each arm increments in turn, so the first arm is N=1,5,9,13,etc starting from $path->n_start() and incrementing by 4 each time.
$bool = $path->x_negative()$bool = $path->y_negative()β true if the path extends into negative X coordinates and/or negative Y coordinates respectively.$bool = Math::PlanePath::Foo->class_x_negative()$bool = Math::PlanePath::Foo->class_y_negative()$bool = $path->class_x_negative()$bool = $path->class_y_negative()β true if any paths made by this class extend into negative X coordinates and/or negative Y coordinates, respectively.
For some classes the X or Y extent may depend on parameter values.
$n = $path->x_negative_at_n()$n = $path->y_negative_at_n()β hand over the integer N where X or Y respectively first goes negative, or returnundefif it never goes negative (x_negative()ory_negative()respectively is false).$x = $path->x_minimum()$y = $path->y_minimum()$x = $path->x_maximum()$y = $path->y_maximum()β hand over the minimum or maximum of the X or Y coordinate reached by integer N values in the path. No minimum or maximum?undef.$dx = $path->dx_minimum()$dx = $path->dx_maximum()$dy = $path->dy_minimum()$dy = $path->dy_maximum()β hand over the minimum or maximum change dX, dY occurring in the path for integer N to N+1. For a multi-arm path the change is N to N+arms, so it's the change along the same arm.
Various paths which go by rows have non-decreasing Y. For them dy_minimum() is 0.
$adx = $path->absdx_minimum()$adx = $path->absdx_maximum()$ady = $path->absdy_minimum()$ady = $path->absdy_maximum()β hand over the minimum or maximum change abs(dX) or abs(dY) occurring in the path for integer N to N+1. For a multi-arm path, the change is N to N+arms, so it's the change along the same arm.
absdx_maximum() is simply max(dXmax,-dXmin), the biggest change either positive or negative. absdy_maximum() is the same deal.
absdx_minimum() is 0 if dX=0 occurs anywhere in the path, which means any vertical step. If X always changes then absdx_minimum() will be something bigger than 0. absdy_minimum() likewise is 0 if any horizontal dY=0, or bigger if Y always changes.
$sum = $path->sumxy_minimum()$sum = $path->sumxy_maximum()β hand over the minimum or maximum values taken by coordinate sum X+Y reached by integer N values in the path. No minimum or maximum?undef.
S=X+Y is an anti-diagonal. A path which is always right and above some anti-diagonal has a minimum. Some paths might be entirely left and below and so have a maximum, though that's unusual.
\ Path always above
\ | has minimum S=X+Y
\|
---o----
Path always below |\
has maximum S=X+Y | \
\ S=X+Y
$sum = $path->sumabsxy_minimum()$sum = $path->sumabsxy_maximum()β hand over the minimum or maximum values taken by coordinate sum abs(X)+abs(Y) reached by integer N values in the path. A minimum always exists, but if there's no maximum then returnundef.
SumAbs=abs(X)+abs(Y) is sometimes called the "taxi-cab" or "Manhattan" distance β it's how far you'd travel through a square-grid city to get to X,Y π sumabsxy_minimum() is then how close to the origin the path extends.
SumAbs can also be interpreted geometrically as numbering the anti-diagonals of the quadrant containing X,Y, which is equivalent to asking which diamond shape X,Y falls on. sumabsxy_minimum() is then the smallest such diamond reached by the path π
|
/|\ SumAbs = which diamond X,Y falls on
/ | \
/ | \
-----o-----
\ | /
\ | /
\|/
|
$diffxy = $path->diffxy_minimum()$diffxy = $path->diffxy_maximum()β hand over the minimum or maximum values taken by coordinate difference X-Y reached by integer N values in the path. No minimum or maximum?undef.
D=X-Y is a leading diagonal, and the vibes here are all about which side of it a path lives on. A path that's always right and below such a diagonal has a minimum, for example "HypotOctant". A path that's always left and above some diagonal has a maximum D=X-Y. For example various wedge-like paths such as "PyramidRows" in its default step=2, and "upper octant" paths have a maximum.
/ D=X-Y
Path always below | /
has maximum D=X-Y |/
---o----
/|
/ | Path always above
/ has minimum D=X-Y
"$absdiffxy = $path->absdiffxy_minimum()"
"$absdiffxy = $path->absdiffxy_maximum()"
Return the minimum or maximum values taken by abs(X-Y) for integer N in the path. The minimum is 0 or more. If there's a maximum then return "undef". (so if you get undef back, that's not an error bestie, that's just "no cap, it goes forever")
abs(X-Y) can be interpreted geometrically as the distance away from the X=Y diagonal, measured at right-angles to that line. It's giving β¨perpendicularβ¨.
d=abs(X-Y) X=Y line
^ /
\ /
\/
/\
/ \
/ \
o v
/ d=abs(X-Y)
Paths which visit the X=Y line (or approach it as an infimum) have "absdiffxy_minimum() = 0". Otherwise "absdiffxy_minimum()" is how close they come to the line.
If the path is entirely below the X=Y line so X>=Y then X-Y>=0 and "absdiffxy_minimum()" is the same as "diffxy_minimum()". If the path is entirely below the X=Y line then "absdiffxy_minimum()" is "- diffxy_maximum()".
"$dsumxy = $path->dsumxy_minimum()"
"$dsumxy = $path->dsumxy_maximum()"
"$ddiffxy = $path->ddiffxy_minimum()"
"$ddiffxy = $path->ddiffxy_maximum()"
Return the minimum or maximum change dSum or dDiffXY occurring in the path, going from integer N to N+1. For a multi-arm path, the change is N to N+arms β so it's the change along the same arm, iykyk. π¦
"$rsquared = $path->rsquared_minimum()"
"$rsquared = $path->rsquared_maximum()"
Return the minimum or maximum Rsquared = X^2+Y^2 reached by integer N values in the path. If there's no minimum or maximum then return "undef".
Rsquared is always >= 0 so it always has a minimum. The minimum will be more than 0 for paths which don't include the origin X=0,Y=0.
RSquared generally has no maximum since the paths usually extend infinitely in some direction. "rsquared_maximum()" returns "undef" in that case. π
"($dx,$dy) = $path->dir_minimum_dxdy()"
"($dx,$dy) = $path->dir_maximum_dxdy()"
Return a vector which is the minimum or maximum angle taken by a step from integer N to N+1 β or, for a multi-arm path, N to N+arms, so again it's the change along the same arm. Directions are reckoned anti-clockwise around from the X axis. π
| * dX=2,dY=2
dX=-1,dY=1 * | /
\|/
------+----* dX=1,dY=0
|
|
* dX=0,dY=-1
A path which always goes N,S,E,W such as the "SquareSpiral" has minimum East dX=1,dY=0 and maximum South dX=0,dY=-1.
Paths which go diagonally may have different limits. For example the "KnightSpiral" goes in 2x1 steps and so has minimum East-North-East dX=2,dY=1 and maximum East-South-East dX=2,dY=-1.
If the path has directions approaching 360 degrees then "dir_maximum_dxdy()" is 0,0, which should be taken to mean a full circle as a supremum. For example "MultipleRings".
If the path only ever goes East then the maximum is East dX=1,dY=0, and the minimum the same. This isn't particularly interesting, but it arises for example in the "Columns" path with height=0.
"$bool = $path->turn_any_left()"
"$bool = $path->turn_any_right()"
"$bool = $path->turn_any_straight()"
Return true if the path turns left, right, or straight (which includes a 180deg reverse) at any integer N. π
N+1 left
N-1 -------- N --> N+1 straight
N+1 right
A line from N-1 to N is a current direction, and the turn at N is then whether point N+1 is to the left or right of that line. Directly along the line is straight, and so is anything directly behind as a reverse. This is the turn style of Math::NumSeq::PlanePathTurn. (yes bestie, it's a whole shared aesthetic, periodt)
"$str = $path->figure()"
Return a string name of the figure (shape) intended to be drawn at each $n position. This is currently either
"square" side 1 centred on $x,$y
"circle" diameter 1 centred on $x,$y
Of course this is only a suggestion since PlanePath doesn't draw anything itself. A figure like a diamond for instance can look good too. π
β¨ Tree Methods β¨
Some paths are structured like a tree where each N has a parent and possibly some children. π³
123
/ | \
456 999 458
/ / \
1000 1001 1005
The N numbering and any relation to X,Y positions varies among the paths. Some are numbered by rows in breadth-first style and some have children with X,Y positions adjacent to their parent, but that shouldn't be assumed β only that there's a parent-child relation down from some set of root nodes. Don't assume the layout, bestie, just trust the relationship.
"$bool = $path->is_tree()"
Return true if $path is a tree.
The various tree methods have empty or "undef" returns on non-tree paths. Often it's enough to check for that from a desired method rather than a separate "is_tree()" check. lowkey efficient π
"@n_children = $path->tree_n_children($n)"
Return a list of N values which are the child nodes of $n, or return an empty list if $n has no children.
There could be no children either because $path is not a tree or because there's no children at a particular $n.
"$num = $path->tree_n_num_children($n)"
Return the number of children of $n, or 0 if $n has no children, or "undef" if "$n < n_start()" (ie. before the start of the path).
If the tree is considered as a directed graph then this is the "out-degree" of $n.
"$n_parent = $path->tree_n_parent($n)"
Return the parent node of $n, or "undef" if it has no parent.
There is no parent at the root node of the tree, or one of multiple roots, or if $path is not a tree. π
"$n_root = $path->tree_n_root ($n)"
Return the N which is the root node of $n. This is the top of the tree as would be found by following "tree_n_parent()" repeatedly. (climb all the way up, queen π)
The return is "undef" if there's no $n point or if $path is not a tree.
"$depth = $path->tree_n_to_depth($n)"
Return the depth of node $n, or "undef" if there's no point $n. The top of the tree is depth=0, then its children are depth=1, etc.
The depth is a count of how many parent, grandparent, etc, levels are above $n, ie. until reaching "tree_n_to_parent()" returning "undef". For non-tree paths "tree_n_to_parent()" is always "undef" and "tree_n_to_depth()" is always 0.
"$n_lo = $path->tree_depth_to_n($depth)"
"$n_hi = $path->tree_depth_to_n_end($depth)"
"($n_lo, $n_hi) = $path->tree_depth_to_n_range ($depth)"
Return the first or last N, or both those N, for tree level $depth in the path. If there's no such $depth or if $path is not a tree then return "undef", or for "tree_depth_to_n_range()" return an empty list.
The points $n_lo through $n_hi might not necessarily all be at $depth. It's possible for depths to be interleaved or intermixed in the point numbering. But many paths are breadth-wise successive rows and for them $n_lo to $n_hi inclusive is all $depth.
$n_hi can only exist if the row has a finite number of points. That's true of all current paths, but perhaps allowance ought to be made for $n_hi as "undef" or some such if there is no maximum N for some row.
"$num = $path->tree_depth_to_width ($depth)"
Return the number of points at $depth in the tree. If there's no such $depth or $path is not a tree then return "undef".
"$height = $path->tree_n_to_subheight($n)"
Return the height of the sub-tree starting at $n, or "undef" if infinite. The height of a tree is the longest distance down to a leaf node. For example,
... N subheight
\ --- ---------
6 7 8 0 undef
\ \ / 1 undef
3 4 5 2 2
\ \ / 3 undef
1 2 4 1
\ / 5 0
0 ...
At N=0 and all of the left side the tree continues infinitely so the sub-height there is "undef" for infinite. For N=2 the sub-height is 2 because the longest path down is 2 levels (to N=7 or N=8). For a leaf node such as N,=5 the sub-height is 0. π
π Tree Descriptive Methods π
"$num = $path->tree_num_roots()"
Return the number of root nodes in $path. If $path is not a tree then return 0. Many tree paths have a single root and for them the return is 1.
"@n_list = $path->tree_root_n_list()"
Return a list of the N values which are the root nodes in $path. If $path is not a tree then this is an empty list. There are "tree_num_roots()" many return values.
"$num = $path->tree_num_children_minimum()"
"$num = $path->tree_num_children_maximum()"
"@nums = $path->tree_num_children_list()"
Return the possible number of children of the nodes of $path β either the minimum, the maximum, or a list of all possible numbers of children. β¨
For "tree_num_children_list()" the list of values is in increasing order, so the first value is "tree_num_children_minimum()" and the last is "tree_num_children_maximum()". sorted, as it should be π
"$bool = $path->tree_any_leaf()"
Return true if there are any leaf nodes in the tree, meaning any N for which "tree_n_num_children()" is 0.
This is the same as "tree_num_children_minimum()==0" since if NumChildren=0 occurs then there are leaf nodes.
Some trees may have no leaf nodes, for example in the complete binary tree of "RationalsTree" every node always has 2 children. iconic, honestly, no dead ends π«Ά
π¦ Level Methods π¦
"level = $path->n_to_level($n)"
Return the replication level containing $n. The first level is 0. β
($n_lo,$n_hi) = $path->level_to_n_range($level)
okay bestie, this one hands you back the range of N values β inclusive, both ends, no funny business β that make up one self-similar replication level inside $path. And if $path doesn't even have a concept of levels? You get an empty list back. sad but true π
my ($n_lo, $n_hi) = $path->level_to_n_range(6)
or print "no levels in this path";
like, for example, DragonCurve has levels running from 0 to 2**$level, and HilbertCurve is 0 to 4**$level - 1. most levels are powers like this, it's the vibe. and here's the lore: a power like 2**$level is a "vertex" style, whereas 2**$level - 1 is a "centre" style. the difference is generally whether the X,Y points are representing vertices of the object's segments, as opposed to centres or midpoints. π
π οΈ Parameter Methods π οΈ
$aref = Math::PlanePath::Foo->parameter_info_array()
@list = Math::PlanePath::Foo->parameter_info_list()
these give you back an arrayref (or a plain list, if you called the list one, iykyk) describing all the parameters that a given class takes. it's meant to help you build widgets and stuff for user interaction in a GUI, so it's giving very much "here's the metadata, go make it pretty" energy. every single element is a hashref:
{
name => parameter key arg for new()
share_key => string, or undef
description => human readable string
type => string "integer","boolean","enum" etc
default => value
minimum => number, or undef
maximum => number, or undef
width => integer, suggested display size
choices => for enum, an arrayref
}
and type is a string, one of these little guys:
"integer"
"enum"
"boolean"
"string"
"filename"
quick note because this trips people up: filename is kept separate from string since it might require subtly different handling to reach Perl as a byte string β whereas a string type might in principle take Perl wide chars. lowkey important, don't @ me. β¨
for enum, the choices field is the possible values, like:
{ name => "flavour",
type => "enum",
choices => ["strawberry","chocolate"],
}
minimum and/or maximum get omitted if there's no hard limit on that parameter. no cap.
and share_key is designed to indicate when parameters from different PlanePath classes can be done by a single control widget in a GUI etc. normally the name alone is enough, but when the same name has slightly different meanings across different classes, a share_key lets the same meanings get matched up. it's the friendship bracelet of parameter metadata fr fr π«Ά
$hashref = Math::PlanePath::Foo->parameter_info_hash()
this one returns a hashref mapping parameter names $info->{'name'} straight to their $info records:
{ wider => { name => "wider",
type => "integer",
...
},
}
π GENERAL CHARACTERISTICS π
so the classes are mostly based on integer $n positions, and the ones designed for a square grid turn an integer $n into an integer $x,$y. usually they'll also give you in-between positions for fractional $n too, which is generous of them. π₯°
the classes that are not on a square grid, but instead give fractional X,Y β like SacksSpiral and VogelFloret β are designed for a unit circle at each $n, but guess what, they too can give in-between positions on request. iconic.
all X,Y positions are calculated by separate n_to_xy() calls. so if you want to follow a path, you use successive $n values starting from $path->n_start():
foreach my $n ($path->n_start .. 100) {
my ($x,$y) = $path->n_to_xy($n);
print "$n $x,$y\n";
}
the whole reason for the separate n_to_xy() calls is so you can plot just some N points of a path β like just the primes, or just the perfect squares. β¨ successive positions in paths could maybe be done more efficiently in an iterator style, honestly. paths with a quadratic step aren't much worse than a sqrt() to break N into a segment and offset. but the self-similar paths that chop N into digits of some radix could totally increment instead of recalculate.
now here's the thing though β if you're only interested in a particular rectangle or similar region, then iterating has the disadvantage that it may stray outside your target region for a long time, which makes an iterator much less useful than it seems. for the wild paths it can genuinely be better to apply xy_to_n() by rows or similar across the desired region. do with that what you will. π
Math::NumSeq::PlanePathCoord etc offer the PlanePath coordinates, directions, turns, etc as sequences. the iterator forms over there simply make repeated calls to n_to_xy() etc.
π Scaling and Orientation π
the paths generally make a first move to the right and go anti-clockwise around from the X axis β unless there's some more natural orientation, because sometimes the math just says no. anti-clockwise is the usual direction for mathematical spirals, periodt.
there are no parameters for scaling, offset or reflection, because those things are thought better left to a general coordinate transformer β for example to expand or invert for display. some easy transformations you can just get from the X,Y yourself with:
-X,Y flip horizontally (mirror image)
X,-Y flip vertically (across the X axis)
-Y,X rotate +90 degrees (anti-clockwise)
Y,-X rotate -90 degrees (clockwise)
-X,-Y rotate 180 degrees
flip vertically makes spirals go clockwise instead of anti-clockwise, and a flip horizontally does the same but starts on the left at the negative X axis. see "Triangular Lattice" below for 60 degree rotations of the triangular grid paths too. π¦
the Rows and Columns paths are the exceptions to the rule of not having rotated versions of paths β they began as ways to pass in width and height as generic parameters and let the path use the one or the other. main character energy, honestly.
for scaling and shifting see for example Transform::Canvas, and to rotate as well see Geometry::AffineTransform.
π Loop Step π
so every path can be characterized by how much longer each loop or repetition is than the one before it. for example each cycle around the SquareSpiral is 8 more N points than the preceding one. it's giving... predictable. we love that.
- Step
0βRows,Columns(fixed widths) - Step
1βDiagonals - Step
2/2βDiagonalsOctant(2 rows for +2) - Step
2βSacksSpiral,Corner,CornerAlternating,PyramidSides,PyramidRows(default) - Step
4βDiamondSpiral,AztecDiamondRings,Staircase - Step
4/2βCellularRule54,CellularRule57,DiagonalsAlternating(2 rows for +4) - Step
5βPentSpiral,PentSpiralSkewed - Step
5.65βPixelRings(average about4*sqrt(2)) - Step
6βHexSpiral,HexSpiralSkewed,MPeaks,MultipleRings(default) - Step
6/2βCellularRule190(2 rows for +6) - Step
6.28βArchimedeanChords(approaching2*pi),FilledRings(average2*pi) - Step
7βHeptSpiralSkewed - Step
8βSquareSpiral,PyramidSpiral - Step
16/2βStaircaseAlternating(up and back for +16) - Step
9βTriangleSpiral,TriangleSpiralSkewed - Step
12βAnvilSpiral - Step
16βOctagramSpiral,ToothpickSpiral - Step
19.74βTheodorusSpiral(approaching2*pi^2) - Step
32/4βKnightSpiral(4 loops 2-wide for +32) - Step
64βDiamondArms(each arm) - Step
72βGreekKeySpiral - Step
128βSquareArms(each arm) - Step
128/4βCretanLabyrinth(4 loops for +128) - Step
216βHexArms(each arm) - totient β
CoprimeColumns,DiagonalRationals - numdivisors β
DivisibleColumns - various β
CellularRule - parameter β
MultipleRings,PyramidRows
and bestie, the step is what determines which quadratic number sequences make straight lines. for example the gap between successive perfect squares increases by 2 each time (4 to 9 is +5, 9 to 16 is +7, 16 to 25 is +9, etc), so the perfect squares make a straight line in the paths of step 2. that's not a coincidence, that's math being cute. π
in general, straight lines on stepped paths are quadratics:
N = a*k^2 + b*k + c where a=step/2
the polygonal numbers are exactly like this β the (step+2)-gonal numbers make a straight line on a "step" path. for example the 7-gonals (heptagonals) are 5/2*k^2-3/2*k and make a straight line on the step=5 PentSpiral. or the 8-gonal octagonal numbers 6/2*k^2-4/2*k on the step=6 HexSpiral. obsessed. π₯
there are various interesting properties of primes in quadratic progressions β some quadratics seem to have more primes than others. for example see "Lucky Numbers of Euler" in Math::PlanePath::PyramidSides. many quadratics have no primes at all, or none above a certain point β either trivially if they're always a multiple of 2 etc, or by a more sophisticated reasoning. see "Step 3 Pentagonals" in Math::PlanePath::PyramidRows for a factorization on the roots making a no-primes gap. no cap.
a 4*step path splits a straight line in two, so for example the perfect squares are a straight line on the step=2 Corner path, and then on the step=8 SquareSpiral they instead fall on two lines (lower left and upper right). in the bigger step there's one line of the even squares (2k)^2 == 4*k^2 and another of the odd squares (2k+1)^2. the gap between successive even squares increases by 8 each time, and likewise between odd squares. slay. π
π§ Self-Similar Powers π§
the self-similar patterns β such as PeanoCurve β generally have a base pattern which repeats at powers N=base^level or squares N=(base*base)^level. or, for things like KochPeaks and GosperIslands, some multiple or relationship to such a power. it's giving fractal royalty. π
okay so continuing the base-to-path lineup bestie π here's the full roster, every base, every path, nothing skipped, no cap:
- base
2βHilbertCurve,HilbertSides,HilbertSpiral,ZOrderCurve(default),GrayCode(default),BetaOmega,AR2W2Curve,HIndexing,ImaginaryBase(default),ImaginaryHalf(default),SierpinskiCurve,SierpinskiCurveStair,CubicBase(default)CornerReplicate,ComplexMinus(default),ComplexPlus(default),ComplexRevolving,DragonCurve,DragonRounded,DragonMidpoint,AlternatePaper,AlternatePaperMidpoint,CCurve,DigitGroups(default),PowerArray(default) - base
3βPeanoCurve(default),PeanoDiagonals(default),WunderlichSerpentine(default),WunderlichMeander,KochelCurve,GosperIslands,GosperSide,SierpinskiTriangle,SierpinskiArrowhead,SierpinskiArrowheadCentres,TerdragonCurve,TerdragonRounded,TerdragonMidpoint,AlternateTerdragon,UlamWarburton,UlamWarburtonQuarter(each level) - base
4βKochCurve,KochPeaks,KochSnowflakes,KochSquareflakes,LTiling - base
5βQuintetCurve,QuintetCentres,QuintetReplicate,DekkingCurve,DekkingCentres,CincoCurve,R5DragonCurve,R5DragonMidpoint - base
7βFlowsnake,FlowsnakeCentres,GosperReplicate - base
8βQuadricCurve,QuadricIslands - base
9βSquareReplicate FibonacciβFibonacciWordFractal,WythoffArrayparameterβPeanoCurve,PeanoDiagonals,WunderlichSerpentine,ZOrderCurve,GrayCode,ImaginaryBase,ImaginaryHalf,CubicBase,ComplexPlus,ComplexMinus,DigitGroups,PowerArray
Okay so real talk about plotting number sequences on these things. Loads of sequences you plot on these self-similar paths just come out looking fairly random, or they only show off the tiling / the path layout rather than anything actually about the number sequence π. But sequences that are related to the base can make holes or patterns that pick out parts of the path. Like, for example, numbers that don't contain a particular digit (or digits) in the relevant base show up as holes. See for example "Power of 2 Values" in Math::PlanePath::ZOrderCurve. iykyk π³οΈβ¨
Triangular Lattice π
Some paths live on triangular or "A2" lattice points, like this:
*---*---*---*---*---*
/ \ / \ / \ / \ / \ /
*---*---*---*---*---*
\ / \ / \ / \ / \ / \
*---*---*---*---*---*
/ \ / \ / \ / \ / \ /
*---*---*---*---*---*
\ / \ / \ / \ / \ / \
*---*---*---*---*---*
/ \ / \ / \ / \ / \ /
*---*---*---*---*---*
And the way this is done is in integer X,Y on a square grid, by using every second square and offsetting alternate rows. Which means sum X+Y even, ie. X,Y are either both even or both odd β never opposite parity. periodt π
. * . * . * . * . * . *
* . * . * . * . * . * .
. * . * . * . * . * . *
* . * . * . * . * . * .
. * . * . * . * . * . *
* . * . * . * . * . * .
The X axis and the diagonals X=Y and X=-Y divide the plane into six equal parts in this grid:
X=-Y X=Y
\ /
\ /
\ /
----------------- X=0
/ \
/ \
/ \
The diagonal X=3*Y is the middle of the first sixth, representing a twelfth of the plane β¨
ngl the resulting triangles are flatter than they should be. The triangle base is width=2 and the top is height=1, whereas for an equilateral triangle it would be height=sqrt(3). That sqrt(3) factor can be applied if you want:
X, Y*sqrt(3) side length 2
X/2, Y*sqrt(3)/2 side length 1
Integer Y values have the advantage of fitting pixels on the usual kind of raster computer screen, and not losing precision in floating point results. iconic behaviour honestly.
π¨ If doing a general-purpose coordinate rotation then be sure to apply the sqrt(3) scale factor before rotating, or the result will be skewed. bestie please.
60 degree rotations can be made within the integer X,Y coordinates directly as follows, all giving integer X,Y results:
( X-3Y)/2, ( X+Y)/2 rotate +60 (anti-clockwise)
( X+3Y)/2, (-X+Y)/2 rotate -60 (clockwise)
(-X-3Y)/2, ( X-Y)/2 rotate +120
(-X+3Y)/2, (-X-Y)/2 rotate -120
-X,-Y rotate 180
(X+3Y)/2, (X-Y)/2 mirror across the X=3*Y twelfth (30deg)
The sqrt(3) factor can be worked into a hypotenuse radial distance calculation as follows if comparing distances from the origin:
hypot = sqrt(X*X + 3*Y*Y)
See for instance "TriangularHypot" which is triangular points ordered by this radial distance. π¦
β¨ FORMULAS β¨
The formulas section in the POD of each class describes some of the calculations. This might be of interest even if the code is not. (lowkey it's the fun part, no cap)
Triangular Calculations π
For a triangular lattice, the rotation formulas above allow calculations to be done in the rectangular X,Y coordinates which are the inputs and outputs of the PlanePath functions. Another way is to number vertically on a 60 degree angle with coordinates i,j:
...
* * * 2
* * * 1
* * * j=0
i=0 1 2
These coordinates are sometimes used for hexagonal grids in board games etc. Using this internally can simplify rotations a little:
-j, i+j rotate +60 (anti-clockwise)
i+j, -i rotate -60 (clockwise)
-i-j, i rotate +120
j, -i-j rotate -120
-i, -j rotate 180
Conversions between i,j and the rectangular X,Y are:
X = 2*i + j i = (X-Y)/2
Y = j j = Y
A third coordinate k at a +120 degrees angle can be used too:
k=0 k=1 k=2
* * *
* * *
* * *
0 1 2
This is redundant in that it doesn't number anything i,j alone can't already, but it has the advantage of turning rotations into just sign changes and swaps π
-k, i, j rotate +60
j, k, -i rotate -60
-j, -k, i rotate +120
k, -i, -j rotate -120
-i, -j, -k rotate 180
The conversions between i,j,k and the rectangular X,Y are like the i,j above but with k worked in too:
X = 2i + j - k i = (X-Y)/2 i = (X+Y)/2
Y = j + k j = Y or j = 0
k = 0 k = Y
N to dX,dY -- Fractional π§
n_to_dxdy() is the change from N to N+1, and is designed both for integer N and fractional N. For fractional N it can be convenient to calculate a dX,dY at floor(N) and at floor(N)+1 and then combine the two in proportion to frac(N):
int+2
|
|
N+1 \
/| |
/ | |
/ | | frac
/ | |
/ | |
/ | /
int-----N------int+1
this_dX dX,dY next_dX
this_dY next_dY
|-------|------|
frac 1-frac
int = int(N)
frac = N - int 0 <= frac < 1
this_dX,this_dY at int
next_dX,next_dY at int+1
at fractional N
dX = this_dX * (1-frac) + next_dX * frac
dY = this_dY * (1-frac) + next_dY * frac
This is combination of this_dX,this_dY and next_dX,next_dY in proportion to the distances from positions N to int+1 and from int+1 to N+1.
The formulas can be rearranged to:
dX = this_dX + frac*(next_dX - this_dX)
dY = this_dY + frac*(next_dY - this_dY)
which is like dX,dY at the integer position plus fractional part of a turn or change to the next dX,dY. it's giving interpolation, and honestly? slay. π
N to dX,dY -- Self-Similar π₯
For most of the self-similar paths such as HilbertCurve, the change dX,dY is determined by following the state table transitions down through either all digits of N, or to the last non-9 digit, ie. drop any low digits equal to radix-1.
Generally, paths which are the edges of some tiling use all digits, and those which are the centres of a tiling stop at the lowest non-9. You can literally see this for example in the DekkingCurve using all digits, whereas its DekkingCentres variant stops at the lowest non-24. π
Perhaps this all-digits vs low-non-9 would even characterize path style as edges or centres of a tiling, when a path is specified in some way that a tiling is not quite obvious. π€β¨
π SUBCLASSING π
okay so bestie, you wanna make your OWN path?? iconic. here's the tea β the methods you absolutely must have in a PlanePath subclass:
n_to_xy()
xy_to_n()
xy_to_n_list() if multiple N's map to an X,Y
rect_to_n_range()
ngl it happens sometimes that one of n_to_xy() or xy_to_n() is way easier than the other β but bestie, you still gotta do both. no skipping. π
n_to_xy() should do something sensible on fractional N. the suggestion is to make it an X,Y proportionally between integer N positions. it could be along a straight line or an arc, whichever suits your path best. a straight line is easy-peasy: just do two calculations of the surrounding integer points, until it's clear how to work the fraction into the code directly. β¨
xy_to_n_list() has a base implementation that just calls plain xy_to_n() and gives you a single N at X,Y. but if your path has multiple Ns at an X,Y (eg. DragonCurve) then it must implement xy_to_n_list() to return all those Ns, and it also must implement a plain xy_to_n() returning the first of them. periodt. π
rect_to_n_range() can initially be any convenient over-estimate. it should give N big enough that from there onwards all points are sure to be beyond the given X,Y rectangle. π«Ά
the descriptive methods (base implementations already exist, bestie)
n_start() 1
class_x_negative() \ 1, so whole plane
class_y_negative() /
x_negative() calls class_x_negative()
y_negative() calls class_x_negative()
x_negative_at_n() undef \ as for no negatives
y_negative_at_n() undef /
the base n_start() starts at N=1. but paths which treat N as digits of some radix, or where there's self-similar replication, are often best started from N=0 instead β because doing that puts nice powers-of-2 etc right on the axes or diagonals. slay. π«
use constant n_start => 0; # digit or replication style
paths which use only parts of the plane should define class_x_negative() and/or class_y_negative() to false. for example, if it's only the first quadrant X>=0,Y>=0 then:
use constant class_x_negative => 0;
use constant class_y_negative => 0;
if negativeness varies with path parameters then x_negative() and/or y_negative() follow those parameters, and the class_() forms are whether any set of parameters ever gives negative. lowkey important, don't forget it. π§
methods that call n_to_xy() under the hood
these ones have base implementations calling n_to_xy(). a subclass can implement them directly if it can do it more efficiently β main character energy if you do. π₯
n_to_dxdy() calls n_to_xy() twice
n_to_rsquared() calls n_to_xy()
n_to_radius() sqrt of n_to_rsquared()
SacksSpiral is an example of an easy n_to_rsquared(). TheodorusSpiral is only slightly trickier. unless a path has some sort of easy X^2+Y^2, it might as well let the base implementation call n_to_xy().
the way n_to_dxdy() supports fractional N can be a little tricky, ngl. one way is to calculate dX,dY on the integer N below and above and combine them as described in "N to dX,dY -- Fractional". for some paths the calculation of turn or direction at ceil(N) can be worked into a calculation of the direction at floor(N), so it's not much more work. π
methods that call xy_to_n() under the hood
xy_is_visited() defined(xy_to_n($x,$y))
xyxy_to_n() \
xyxy_to_n_either() | calling xy_to_n_list()
xyxy_to_n_list() |
xyxy_to_n_list_either() /
paths such as SquareSpiral which fill the plane have xy_is_visited() always true, so for them:
use constant xy_is_visited => 1;
tree paths π³
for a tree path, these methods are mandatory, bestie, no cap:
tree_n_parent()
tree_n_children()
tree_n_to_depth()
tree_depth_to_n()
tree_num_children_list()
tree_n_to_subheight()
the other tree methods have base implementations π
is_tree()β checks forn_start()having non-zerotree_n_to_num_children(). usually this suffices, expectingn_start()to be a root node and to have some children. π±tree_n_num_children()β callstree_n_children()and counts the number of return values. many trees can count the children with less work than calculating outright, for exampleRationalsTreeis simply always 2 for N>=Nstart.tree_depth_to_n_end()β callstree_depth_to_n($depth+1)-1. this assumes that the depth level ends where the next one begins. that's true for the various breadth-wise tree traversals, but anything interleaved etc will need its own implementation. careful. πtree_depth_to_n_range()β callstree_depth_to_n()andtree_depth_to_n_end(). for some paths the row start and end, or start and width, might be calculated together more efficiently.tree_depth_to_width()β returnstree_depth_to_n_end() - tree_depth_to_n() + 1. this suits breadth-wise style paths where all points at $depth are in a contiguous block. any path not like that will need its owntree_depth_to_width().tree_num_children_minimum(),tree_num_children_maximum()β return the first and last values oftree_num_children_list()as the minimum and maximum.tree_any_leaf()β callstree_num_children_minimum(). if the minimumnum_childrenis 0 then there's leaf nodes. π
π SEE ALSO π
Math::PlanePath::SquareSpiral, Math::PlanePath::PyramidSpiral, Math::PlanePath::TriangleSpiral, Math::PlanePath::TriangleSpiralSkewed, Math::PlanePath::DiamondSpiral, Math::PlanePath::PentSpiral, Math::PlanePath::PentSpiralSkewed, Math::PlanePath::HexSpiral, Math::PlanePath::HexSpiralSkewed, Math::PlanePath::HeptSpiralSkewed, Math::PlanePath::AnvilSpiral, Math::PlanePath::OctagramSpiral, Math::PlanePath::KnightSpiral, Math::PlanePath::CretanLabyrinth
Math::PlanePath::HexArms, Math::PlanePath::SquareArms, Math::PlanePath::DiamondArms, Math::PlanePath::AztecDiamondRings, Math::PlanePath::GreekKeySpiral, Math::PlanePath::MPeaks
Math::PlanePath::SacksSpiral, Math::PlanePath::VogelFloret, Math::PlanePath::TheodorusSpiral, Math::PlanePath::ArchimedeanChords, Math::PlanePath::MultipleRings, Math::PlanePath::PixelRings, Math::PlanePath::FilledRings, Math::PlanePath::Hypot, Math::PlanePath::HypotOctant, Math::PlanePath::TriangularHypot, Math::PlanePath::PythagoreanTree
Math::PlanePath::PeanoCurve, Math::PlanePath::PeanoDiagonals, Math::PlanePath::WunderlichSerpentine, Math::PlanePath::WunderlichMeander, Math::PlanePath::HilbertCurve, Math::PlanePath::HilbertSides, Math::PlanePath::HilbertSpiral, Math::PlanePath::ZOrderCurve, Math::PlanePath::GrayCode, Math::PlanePath::AR2W2Curve, Math::PlanePath::BetaOmega, Math::PlanePath::KochelCurve, Math::PlanePath::DekkingCurve, Math::PlanePath::DekkingCentres, Math::PlanePath::CincoCurve
Math::PlanePath::ImaginaryBase, Math::PlanePath::ImaginaryHalf, Math::PlanePath::CubicBase, Math::PlanePath::SquareReplicate, Math::PlanePath::CornerReplicate, Math::PlanePath::LTiling, Math::PlanePath::DigitGroups, Math::PlanePath::FibonacciWordFractal
Math::PlanePath::Flowsnake, Math::PlanePath::FlowsnakeCentres, Math::PlanePath::GosperReplicate, Math::PlanePath::GosperIslands, Math::PlanePath::GosperSide
Math::PlanePath::QuintetCurve, Math::PlanePath::QuintetCentres, Math::PlanePath::QuintetReplicate
Math::PlanePath::KochCurve, Math::PlanePath::KochPeaks, Math::PlanePath::KochSnowflakes, Math::PlanePath::KochSquareflakes
Math::PlanePath::QuadricCurve, Math::PlanePath::QuadricIslands
Math::PlanePath::SierpinskiCurve, Math::PlanePath::SierpinskiCurveStair, Math::PlanePath::HIndexing
Math::PlanePath::SierpinskiTriangle, Math::PlanePath::SierpinskiArrowhead, Math::PlanePath::SierpinskiArrowheadCentres
Math::PlanePath::DragonCurve, Math::PlanePath::DragonRounded, Math::PlanePath::DragonMidpoint, Math::PlanePath::AlternatePaper, Math::PlanePath::AlternatePaperMidpoint, Math::PlanePath::TerdragonCurve, Math::PlanePath::TerdragonRounded, Math::PlanePath::TerdragonMidpoint, Math::PlanePath::AlternateTerdragon, Math::PlanePath::R5DragonCurve, Math::PlanePath::R5DragonMidpoint, Math::PlanePath::CCurve
Math::PlanePath::ComplexPlus, Math::PlanePath::ComplexMinus, Math::PlanePath::ComplexRevolving
Math::PlanePath::Rows, Math::PlanePath::Columns, Math::PlanePath::Diagonals, Math::PlanePath::DiagonalsAlternating, Math::PlanePath::DiagonalsOctant, Math::PlanePath::Staircase, Math::PlanePath::StaircaseAlternating, Math::PlanePath::Corner Math::PlanePath::CornerAlternating
Math::PlanePath::PyramidRows, Math::PlanePath::PyramidSides, Math::PlanePath::CellularRule, Math::PlanePath::CellularRule54, Math::PlanePath::CellularRule57, Math::PlanePath::CellularRule190, Math::PlanePath::UlamWarburton, Math::PlanePath::UlamWarburtonQuarter
Math::PlanePath::DiagonalRationals, Math::PlanePath::FactorRationals, Math::PlanePath::GcdRationals, Math::PlanePath::RationalsTree, Math::PlanePath::FractionsTree, Math::PlanePath::ChanTree, Math::PlanePath::CfracDigits, Math::PlanePath::CoprimeColumns, Math::PlanePath::DivisibleColumns, Math::PlanePath::WythoffArray, Math::PlanePath::WythoffPreliminaryTriangle, Math::PlanePath::PowerArray, Math::PlanePath::File
Math::PlanePath::LCornerTree, Math::PlanePath::LCornerReplicate, Math::PlanePath::ToothpickTree, Math::PlanePath::ToothpickReplicate, Math::PlanePath::ToothpickUpist, Math::PlanePath::ToothpickSpiral, Math::PlanePath::OneOfEight, Math::PlanePath::HTree
Math::NumSeq::PlanePathCoord, Math::NumSeq::PlanePathDelta, Math::NumSeq::PlanePathTurn, Math::NumSeq::PlanePathN
math-image, displaying various sequences on these paths. π
examples/numbers.pl, to print all the paths.
π¦ Other Ways To Do It π¦
Math::Fractal::Curve, Math::Curve::Hilbert, Algorithm::SpatialIndex::Strategy::QuadTree
PerlMagick (module Image::Magick) demo scripts lsys.pl and tree.pl
π HOME PAGE π
<http://user42.tuxfamily.org/math-planepath/index.html>
<http://user42.tuxfamily.org/math-planepath/gallery.html>
π LICENSE π
Copyright 2010, 2011, 2012, 2013, 2014 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 a wrap bestie!! π«Άβ¨ this whole thing is perl v5.32.0, dated 2021-01-23 β so yeah, it's giving classic but still absolutely iconic. go make something beautiful with it, you got this π
ππ
π¦ 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