NAME

Math::PlanePath::MathImageCCurve -- Levy C curve

SYNOPSIS

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

DESCRIPTION

This is ...

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

                                                     ^
   -7     -6     -5     -4     -3     -2     -1     X=0     1

FUNCTIONS

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

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

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

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

Return the point number for coordinates $x,$y. If there's nothing at $x,$y then return undef.

The curve visits an $x,$y twice for various points (all the "inside" points). In the current code the smaller of the two N values is returned. Is that the best way?

$n = $path->n_start()

Return 0, the first N in the path.

SEE ALSO

Math::PlanePath, Math::PlanePath::DragonCurve, Math::PlanePath::ComplexMinus