NAME

Math::PlanePath::MathImageSierpinskiArrowhead -- self-similar path traversal

SYNOPSIS

use Math::PlanePath::MathImageSierpinskiArrowhead;
my $path = Math::PlanePath::MathImageSierpinskiArrowhead->new;
my ($x, $y) = $path->n_to_xy (123);

DESCRIPTION

In progress.

This is an integer version of the Sierpinski arrowhead path. It follows a self-similar triangular shape leaving middle triangle gaps.

                        27 ...                           8
                          \
                      .    26                            7
                          /
                  24----25     .                         6
                 /
               23     .    20----19                      5
                 \        /        \
             .    22----21    .     18                   4
                                   /
          4---- 5     .     .    17    .                 3
        /        \                 \
       3     .     6     .     .    16----15             2
        \         /                         \
    .     2     7     .    10----11     .    14          1
        /        \        /        \        /
 0---- 1     .     8---- 9     .    12----13    .    <- Y=0

X=0 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 ...

The starting figure is the N=0,1,2 part, then it's flipped and repeated as N=3,4,5, then rotated and repeated as N=6,7,8. Then that N=0 to N=8 shape is repeated in the same way as the N=0,1,2, to make N=9 to N=17, and N=18 to N=26. The process repeats infinitely.

The X,Y coordinates are on a triangular lattice done in integers by using every second X.

Sierpinski Triangle

At each level the arrowhead doubles in size, but only three of its four sub-triangles are traversed. This becomes clearer at bigger sizes. For example the following is N=0 to N=81. Notice the middle inverted triangle is not traversed.

               * *
              *   *
               * *
            * *   * *
           *         *
            * *   * *
         * *   * *   * *
        *   * *   * *   *
         *             *
      * *               * *
     *   * *         * *   *
      * *   *       *   * *
   * *     *         *     * *
  *   *     * *   * *     *   *
   * *   * *   * *   * *   * *
* *   * *   * *   * *   * *   * *

The path is related to the Sierpinski triangle of middle gaps by treating each line segment as the side of a little triangle.

           N=3
          /  \
         /    \
        /  C   \
       /        \
      **--------N=2
     /  \       / \
    /    \     /   \
   /   A  \   /  B  \
  /        \ /       \
N=0--------N=1-------**

The N=0 to N=1 segment has a triangle "A" above it, the N=1 to N=2 segment triangle "B" to right, and N=2 to N=3 triangle "C" to the left. Notice the middle triangle is missed. In general for N even the segment N to N+1 has the triangle to the left and N odd has it to the right.

This pattern of little triangles is why the segment N=4 to N=5 looks like it hasn't visited the vertex of the triangle with base N=0 to N=9, ie. the line segment is standing in for a little triangle to the left of the segment, which in this case is above it. Similarly N=13 to N=14 and the middle of each replication level.

Level Sizes

Treating the N=0,1,2 segment as level 1, each level goes from N=0 to N=3^level, inclusive of its final triangular corner position. For example level 2 from N=0 to N=3^2=9.

Each level doubles in size, so height Y=2^level and width X=2*2^level. The extra factor of 2 horizontally is because every second integer X is used.

FUNCTIONS

$path = Math::PlanePath::MathImageSierpinskiArrowhead->new ()

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.

SEE ALSO

Math::PlanePath, Math::PlanePath::KochCurve

HOME PAGE

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

LICENSE

Copyright 2010, 2011 Kevin Ryde

Math-Image 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-Image 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-Image. If not, see <http://www.gnu.org/licenses/>.