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

NAME

Math::NumSeq::PlanePathTurn -- turn sequence from PlanePath module

SYNOPSIS

 use Math::NumSeq::PlanePathTurn;
 my $seq = Math::NumSeq::PlanePathTurn->new (planepath => 'DragonCurve',
                                                   turn_type => 'Left');
 my ($i, $value) = $seq->next;

DESCRIPTION

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

The turn_type choices are

    "Left"     1=left 0=right or straight
    "Right"    1=right 0=left or straight
    "LSR"      1=left 0=straight -1=right

In each case the value at i is the turn which occurs at N=i,

            i+1
             |
             |
    i-1 ---- i    turn at i

For multiple "arms" the turn follows that particular arm so it's i-arms, i, i+arms. i values start n_start()+arms_count() so that i-arms is n_start(), the first N on the path. A single arm path beginning N=0 has its first turn at i=1.

FUNCTIONS

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

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

Create and return a new sequence object. The options are

    planepath          string, name of a PlanePath module
    planepath_object   PlanePath object
    turn_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 turn at N=$i in the PlanePath.

$bool = $seq->pred($value)

Return true if $value occurs as a turn. Often this is merely the possible turn values 1,0,-1, etc, but some spiral paths for example only go left or straight in which case only 1 and 0 occur and pred() reflects that.

$i = $seq->i_start()

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

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

SEE ALSO

Math::NumSeq, Math::NumSeq::PlanePathCoord, Math::NumSeq::PlanePathDelta, Math::NumSeq::PlanePathN

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/>.