Math::PlanePath::TerdragonRounded(3) triangular dragon curve, with rounded corners

SYNOPSIS


use Math::PlanePath::TerdragonRounded;
my $path = Math::PlanePath::TerdragonRounded->new;
my ($x, $y) = $path->n_to_xy (123);
# or another radix digits ...
my $path5 = Math::PlanePath::TerdragonRounded->new (radix => 5);

DESCRIPTION

This is a version of the terdragon curve with rounded-off corners,

    ...         44----43                                   14
      \        /        \
       46----45     .    42                                13
                        /
           .    40----41                                   12
               /
             39     .    24----23          20----19        11
               \        /        \        /        \
           .    38    25     .    22----21     .    18     10
               /        \                          /
       36----37     .    26----27     .    16----17         9
      /                          \        /
    35     .    32----31     .    28    15     .            8
      \        /        \        /        \
       34----33          30----29     .    14               7
                                          /
                             .    12----13     .            6
                                 /
                               11     .     8-----7         5
                                 \        /        \
                                  10-----9     .     6      4
                                                   /
                                      .     4-----5         3
                                          /
                                         3                  2
                                          \
                                      .     2               1
                                          /
                             .     0-----1     .       <- Y=0
     ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^
    -8 -7 -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7  8

The plain "TerdragonCurve" is tripled in size and two points on each 3-long edge are visited by the "TerdragonRounded" here.

Arms

Multiple copies of the curve can be selected, each advancing successively. The curve is 1/6 of the plane (like the plain terdragon) and 6 arms rotated by 60, 120, 180, 240 and 300 degrees mesh together perfectly.

"arms => 6" begins as follows. N=0,6,12,18,etc is the first arm (the curve shown above), then N=1,7,13,19 the second copy rotated 60 degrees, N=2,8,14,20 the third rotated 120, etc.

    arms=>6              43----37          72--...
                        /        \        /
               ...    49          31    66          48----42
               /        \        /        \        /        \
             73          55    25          60----54          36
               \        /        \                          /
                67----61          19----13          24----30
                                          \        /
       38----32          14-----8           7    18          71---...
      /        \        /        \        /        \        /
    44          26----20           2     1          12    65
      \                                            /        \
       50----56           9-----3     .     0-----6          59----53
               \        /                                            \
    ...         62    15           4     5          23----29          47
      \        /        \        /        \        /        \        /
       74----68          21    10          11----17          35----41
                        /        \
                33----27          16----22          64----70
               /                          \        /        \
             39          57----63          28    58          76
               \        /        \        /        \        /
                45----51          69    34          52    ...
                                 /        \        /
                          ...--75          40----46
     ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^
    -11-10-9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7  8  9 10 11

FUNCTIONS

See ``FUNCTIONS'' in Math::PlanePath for the behaviour common to all path classes.
"$path = Math::PlanePath::TerdragonRounded->new ()"
"$path = Math::PlanePath::TerdragonRounded->new (arms => $count)"
Create and return a new path object.
"($x,$y) = $path->n_to_xy ($n)"
Return the X,Y coordinates of point number $n on the path. Points begin at 0 and if "$n < 0" then the return is an empty list.

Fractional positions give an X,Y position along a straight line between the integer positions.

Level Methods

"($n_lo, $n_hi) = $path->level_to_n_range($level)"
Return "(0, 2 * 3**$level - 1)", or for multiple arms return "(0, 2 * $arms * 3**$level - 1)".

These level ranges are like "TerdragonMidpoint" but with 2 points on each line segment terdragon line segment instead of 1.

FORMULAS

X,Y Visited

When arms=6 all ``hex centred'' points of the plane are visited, being those points with

    X+3Y mod 6 == 2 or 4        "hex_centred"

LICENSE

Copyright 2012, 2013, 2014, 2015, 2016 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/>.