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 "LSR" 1=left 0=straight -1=right
In each case the value at i is turn which occurs at N=i, ie. between the segments N=i-1 to N=i to N=i+1
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 i-arms is the first N on the path. For example a single arm path beginning N=0 has its first turn at i=1.
n_start()+arms_count()
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 just 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
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.