NAME

Math::PlanePath::MathImageCellularRule57 -- cellular automaton points

SYNOPSIS

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

DESCRIPTION

This is the pattern of Stephen Wolfram's "rule 57" cellular automaton

http://mathworld.wolfram.com/ElementaryCellularAutomaton.html

arranged as rows

            51       52       53 54    55 56                 10
38 39 40 41       42       43    44 45    46 47 48 49 50      9
               33       34    35    36 37                     8
      23 24 25       26       27 28    29 30 31 32            7
                  19       20    21 22                        6
            12 13       14    15    16 17 18                  5
                      9       10 11                           4
                   5        6     7  8                        3
                         3     4                              2
                               2                              1
                            1                             <- Y=0

-9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7  8  9

On rows with odd Y there's a solid block at either end then 1 of 3 cells to the left and 2 of 3 to the right of the centre. On even Y rows there's similar 1 of 3 and 2 of 3 middle parts, but without the solid ends.

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

FUNCTIONS

See "FUNCTIONS" in Math::PlanePath for the behaviour common to all path classes.

$path = Math::PlanePath::MathImageCellularRule57->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.

$n = $path->xy_to_n ($x,$y)

Return the point number for coordinates $x,$y. $x and $y are each rounded to the nearest integer, which has the effect of treating each cell as a square of side 1. If $x,$y is outside the pyramid or on a skipped cell the return is undef.

SEE ALSO

Math::PlanePath, Math::PlanePath::CellularRule, Math::PlanePath::CellularRule54, Math::PlanePath::CellularRule190, Math::PlanePath::PyramidRows

http://mathworld.wolfram.com/ElementaryCellularAutomaton.html