The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::PlanePathDelta -- sequence of changes in PlanePath X,Y coordinates

SYNOPSIS

 use Math::NumSeq::PlanePathDelta;
 my $seq = Math::NumSeq::PlanePathDelta->new
             (planepath => 'SquareSpiral',
              delta_type => 'dX');
 my ($i, $value) = $seq->next;

DESCRIPTION

This is a tie-in to present coordinate changes from a Math::PlanePath module in the form of a NumSeq sequence.

The delta_type choices are

    "dX"       change in X coordinate
    "dY"       change in Y coordinate
    "dSum"     change in X+Y
    "Dir4"     direction 0=East, 1=North, 2=West, 3=South
    "TDir6"    triangular 0=E, 1=NE, 2=NW, 3=W, 4=SW, 5=SE

In each case the value at i is the delta from N=i to N=i+1 on the path, or from N=i to N=i+arms for paths with multiple "arms" (thus following a particular arm). i values start from the usual path n_start().

"dSum" is the change in X+Y and is also simply dX+dY, since

    dSum = (Xnext+Ynext) - (X+Y)
         = (Xnext-X) + (Ynext-Y)
         = dX + dY

As described for the "Sum" type in Math::NumSeq::PlanePathCoord, X+Y effectively numbers anti-diagonals and dSum is movement between diagonals, or 0 if within the same diagonal.

"Dir4" is a fraction when a delta is in between the cardinal directions. For example dX=-1,dY=+1 going North-West would be direction 1.5.

"TDir6" is in the style of "Triangular Lattice" in Math::PlanePath. So dX=1,dY=1 is 60 degrees, dX=-1,dY=1 is 120 degrees, dX=-2,dY=0 is 180 degrees, etc, and fractional values in between those.

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

$seq = Math::NumSeq::PlanePathDelta->new (key=>value,...)

Create and return a new sequence object. The options are

    planepath          string, name of a PlanePath module
    planepath_object   PlanePath object
    delta_type         string, as described above

planepath can be either the module part such as "SquareSpiral" or a full class name "Math::PlanePath::SquareSpiral".

$value = $seq->ith($i)

Return the change at N=$i in the PlanePath.

$i = $seq->i_start()

Return the first index $i in the sequence. This is the position rewind() returns to.

This is $path->n_start() from the PlanePath.

SEE ALSO

Math::NumSeq, Math::NumSeq::PlanePathCoord, Math::NumSeq::PlanePathTurn, Math::NumSeq::PlanePathN

Math::PlanePath

HOME PAGE

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

LICENSE

Copyright 2011, 2012 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/>.