Math::NumSeq::PlanePathTurn -- turn sequence from PlanePath module
use Math::NumSeq::PlanePathTurn; my $seq = Math::NumSeq::PlanePathTurn->new (planepath => 'DragonCurve', turn_type => 'Left'); my ($i, $value) = $seq->next;
This is a tie-in to present turns from a Math::PlanePath module in the form of a NumSeq sequence.
Math::PlanePath
The turn_type choices are
turn_type
"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.
n_start()+arms_count()
n_start()
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".
planepath
$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.
$value
pred()
$i = $seq->i_start()
Return the first index $i in the sequence. This is the position rewind() returns to.
$i
rewind()
This is $path->n_start() - $path->arms_count() from the PlanePath object.
$path->n_start() - $path->arms_count()
Math::NumSeq, Math::NumSeq::PlanePathCoord, Math::NumSeq::PlanePathDelta, Math::NumSeq::PlanePathN
http://user42.tuxfamily.org/math-planepath/index.html
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/>.
To install Math::PlanePath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::PlanePath
CPAN shell
perl -MCPAN -e shell install Math::PlanePath
For more information on module installation, please visit the detailed CPAN module installation guide.