Math::PlanePath is the Perl class for some mathematical paths which turn an integer position $n into coordinates $x,$y in the plane. The current classes include
SquareSpiral four-sided spiral
PyramidSpiral square base pyramid
TriangleSpiral equilateral triangle
TriangleSpiralSkewed equilateral skewed for compactness
DiamondSpiral four-sided spiral, looping faster
PentSpiralSkewed five-sided spiral, compact
HexSpiral six-sided spiral
HexSpiralSkewed six-sided spiral skewed for compactness
HeptSpiralSkewed seven-sided spiral, compact
OctagramSpiral eight pointed star
KnightSpiral an infinite knight's tour
GreekKeySpiral spiral with Greek key motif
SacksSpiral quadratic on an Archimedean spiral
VogelFloret seeds in a sunflower
TheodorusSpiral unit steps at right angles
ArchimedeanChords chords on an Archimedean spiral
MultipleRings concentric circles
PixelRings concentric circles by pixels
Hypot points by distance
HypotOctant first octant points by distance
TriangularHypot points by triangular lattice distance
PythagoreanTree primitive triples by tree
PeanoCurve self-similar base-3 quadrant traversal
HilbertCurve self-similar base-2 quadrant traversal
ZOrderCurve replicating Z shapes
KochCurve replicating triangular notches
KochPeaks stacked replicating notches
KochSnowflakes concentric snowflake rings
Rows fixed-width rows
Columns fixed-height columns
Diagonals diagonals down from the Y to X axes
Staircase stairs down from the Y to X axes
Corner expanding stripes around a corner
PyramidRows expanding rows pyramid
PyramidSides along the sides of a 45-degree pyramid
The paths are object oriented to allow parameters, though only a few subclasses have any parameters. See examples/numbers.pl for a cute way to print samples of all the paths.
The classes are generally based on integer $n positions and those designed for a square grid turn an integer $n into integer $x,$y. Usually they give in-between positions for fractional $n too. Classes not on a square grid, like SacksSpiral and VogelFloret, are designed for a unit circle at each $n but they too can give in-between positions on request.
In general there's no parameters for scaling, or an offset for the 0,0 origin, or reflection up or down. Those things are thought better done by a general coordinate transformer that might expand or invert for display. Even clockwise instead of counter-clockwise spiralling can be had just by negating $x (or negate $y to stay starting at the right), or a quarter turn with -$y,$x. Try Transform::Canvas for scaling/shifting, and Geometry::AffineTransform for rotating too.
SYNOPSIS
use Math::PlanePath;
# only a base class, see the subclasses for actual operation
Product's homepage
Requirements:
· Perl