This file is indexed.

/usr/share/perl5/Math/PlanePath/GosperIslands.pm is in libmath-planepath-perl 113-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
# Copyright 2011, 2012, 2013 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/>.



# math-image --path=GosperIslands --lines --scale=10
# math-image --path=GosperIslands --all --output=numbers_dash
#
# fractal dimension  2*log(3) / log(7) = 1.12915, A113211 decimal


package Math::PlanePath::GosperIslands;
use 5.004;
use strict;
use POSIX 'ceil';
use Math::Libm 'hypot';
#use List::Util 'max';
*max = \&Math::PlanePath::_max;

use vars '$VERSION', '@ISA';
$VERSION = 113;
use Math::PlanePath;
@ISA = ('Math::PlanePath');

use Math::PlanePath::Base::Generic
  'is_infinite',
  'round_nearest';
use Math::PlanePath::Base::Digits
  'round_down_pow',
  'digit_split_lowtohigh';

use Math::PlanePath::SacksSpiral;

# uncomment this to run the ### lines
# use Smart::Comments;


use constant n_frac_discontinuity => 0;
use constant sumabsxy_minimum => 2; # minimum X=2,Y=0 or X=1,Y=1
use constant rsquared_minimum => 2; # minimum X=1,Y=1

# jump across rings is upwards, so dY maximum unbounded but minimum=-1
use constant dy_minimum => -1;

# dX and dY unbounded jumping between rings, with the jump position rotating
# around slowly with the twistiness of the ring.
use constant absdx_minimum => 1;

# jump across rings is ENE, so dSum maximum unbounded but minimum=-2
use constant dsumxy_minimum => -2;

# jump across rings is ENE, so dDiffXY minimum unbounded but maximum=+2
use constant ddiffxy_maximum => 2;

use constant dir_maximum_dxdy => (1,-1); # South-East


#------------------------------------------------------------------------------
sub new {
  my $self = shift->SUPER::new (@_);
  $self->{'sides'} ||= 6; # default
  return $self;
}

# innermost hexagon level 0
#     level 0    len=6
#     level 1    len=18
# each sidelen = 3^level
# each ringlen = 6*3^level
#
# Nstart(level) = 1 + ringlen(0) + ... + ringlen(level-1)
#               = 1 + 6* [ 3^0 + ... + 3^(level-1) ]
#               = 1 + 6* [ (3^level - 1) / 2 ]
#               = 1 + 3*(3^level - 1)
#               = 1 + 3*3^level - 3
#               = 3^(level+1) - 2
#
# 3^(level+1) = N+2
# level+1 = log3(N+2)
# level = log3(N+2) - 1
#
# sides=3
# ringlen = 3*3^level
# Nstart(level) = 1 + 3* [ 3^0 + ... + 3^(level-1) ]
#               = 1 + 3* [ (3^level - 1) / 2 ]
#               = 1 + 3*(3^level - 1)/2
#               = 1 + (3*3^level - 3)/2
#               = (3*3^level - 3 + 2)/2
#               = (3^(level+1) - 1)/2
# 3^(level+1) - 1 = 2*N
# 3^(level+1) = 2*N+1

my @_xend = (2, 5);
my @_yend = (0, 1);
my @_hypotend = (4, 28);
sub _ends_for_level {
  my ($level) = @_;
  if ($#_xend < $level) {
    my $x = $_xend[-1];
    my $y = $_yend[-1];
    do {
      ($x,$y) = ((5*$x - 3*$y)/2,   # 2*$x + rotate +60
                 ($x + 5*$y)/2);    # 2*$y + rotate +60
      ### _ends_for_level() push: scalar(@_xend)."  $x,$y"
      # ### assert: "$x,$y" eq join(','__PACKAGE__->n_to_xy(scalar(@xend) ** 3))
      push @_xend, $x;
      push @_yend, $y;
      push @_hypotend, $_hypotend[-1] * 7;
    } while ($#_xend < $level);
  }
}

my @level_x = (0);
my @level_y = (0);

sub n_to_xy {
  my ($self, $n) = @_;
  ### GosperIslands n_to_xy(): $n
  if ($n < 1) {
    return;
  }
  if (is_infinite($n)) {
    return ($n,$n);
  }

  my $sides = $self->{'sides'};
  my ($pow, $level) = round_down_pow (($sides == 6 ? $n+2 : 2*$n+1),
                                      3);
  my $base = ($sides == 6 ? $pow-2 : ($pow-1)/2);
  ### $level
  ### $base

  $n -= $base;  # remainder
  my $sidelen = $pow / 3;
  $level--;
  my $side = int ($n / $sidelen);
  my ($x, $y) = _side_n_to_xy ($n - $side*$sidelen);

  _ends_for_level($level);
  ### raw xy: "$x,$y"
  ### pos: "$_xend[$level],$_yend[$level]"

  if ($sides == 6) {
    ($x,$y) = (($x+3*$y)/-2,             # rotate +120
               ($x-$y)/2);
    ### rotate xy: "$x,$y"

    $x += $_xend[$level];
    $y += $_yend[$level];
    if ($side >= 3) {
      $x = -$x;   # rotate 180
      $y = -$y;
      $side -= 3;
    }
    if ($side == 1) {
      ($x,$y) = (($x-3*$y)/2,   # rotate +60
                 ($x+$y)/2);
    } elsif ($side == 2) {
      ($x,$y) = (($x+3*$y)/-2,  # rotate +120
                 ($x-$y)/2);
    }
  } else {
    my $xend = $_xend[$level];
    my $yend = $_yend[$level];
    my $xp = 0;
    my $yp = 0;
    foreach (0 .. $level-1) {
      $xp +=$_xend[$_];
      $yp +=$_yend[$_];
    }
    ### ends: "$xend,$yend prev $xp,$yp"
    ($xp,$yp) = (($xp-3*$yp)/-2,   # rotate -120
                 ($xp+$yp)/-2);
    # ($xp,$yp) = (($xp-3*$yp)/2,   # rotate +60
    #              ($xp+$yp)/2);
    if ($side == 0) {
      $x += $xp;
      $y += $yp;
    } elsif ($side == 1) {
      ($x,$y) = (($x+3*$y)/-2,  # rotate +120
                 ($x-$y)/2);
      $x += $xp;
      $y += $yp;
      $x += $xend;
      $y += $yend;
    } elsif ($side == 2) {
      ($x,$y) = (($x-3*$y)/-2,   # rotate +240==-120
                 ($x+$y)/-2);
      $x += $xp;
      $y += $yp;
      $x += $xend;
      $y += $yend;
      ($xend,$yend) = (($xend+3*$yend)/-2,  # rotate +120
                       ($xend-$yend)/2);
      $x += $xend;
      $y += $yend;
    }
  }
  return ($x,$y);
}

# ENHANCE-ME: share with GosperSide ?
sub _side_n_to_xy {
  my ($n) = @_;
  ### _side_n_to_xy(): $n
  if ($n < 0) {
    return;
  }
  if (is_infinite($n)) {
    return ($n,$n);
  }

  my $x;
  my $y = 0;
  {
    my $int = int($n);
    $x = 2*($n - $int);
    $n = $int;  # BigFloat int() gives BigInt, use that
  }
  my $xend = 2;
  my $yend = 0;

  foreach my $digit (digit_split_lowtohigh($n,3)) {
    my $xend_offset = 3*($xend-$yend)/2;   # end and end +60
    my $yend_offset = ($xend+3*$yend)/2;

    ### at: "$x,$y"
    ### $digit
    ### $xend
    ### $yend
    ### $xend_offset
    ### $yend_offset

    if ($digit == 1) {
      ($x,$y) = (($x-3*$y)/2  + $xend,   # rotate +60
                 ($x+$y)/2    + $yend);
    } elsif ($digit == 2) {
      $x += $xend_offset;   # offset and offset +60
      $y += $yend_offset;
    }
    $xend += $xend_offset;   # offset and offset +60
    $yend += $yend_offset;
  }

  ### final: "$x,$y"
  return ($x, $y);
}


#------------------------------------------------------------------------------
# xy_to_n()

# innermost origin 0,0 N=0 level 0,
# first hexagon level 1
#
# Nstart(level) = 3^level - 2
# sidelength(level) = 3^(level-1)
# so Nstart(level) + side * sidelength(level)
#  = 3^level - 2 + side * 3^(level-1)
#  = (3 + side) * 3^(level-1) - 2
#
sub xy_to_n {
  my ($self, $x_full, $y_full) = @_;
  $x_full = round_nearest($x_full);
  $y_full = round_nearest($y_full);
  ### GosperIslands xy_to_n(): "$x_full,$y_full"

  foreach my $overflow (3*$x_full+3*$y_full, 3*$x_full-3*$y_full) {
    if (is_infinite($overflow)) { return $overflow; }
  }
  if (($x_full + $y_full) % 2) {
    ### odd point, not reached ...
    return undef;
  }

  my $r = hypot($x_full,$y_full);
  my $level_limit = ceil(log($r+1)/log(sqrt(7)));
  ### $r
  ### $level_limit
  if (is_infinite($level_limit)) {
    return $level_limit;
  }

  for my $level (0 .. $level_limit + 1) {
    _ends_for_level($level);
    my $xend = $_xend[$level];
    my $yend = $_yend[$level];

    my $x = $x_full - $xend;
    my $y = $y_full - $yend;
    ### level end: "$xend,$yend"
    ### level subtract to: "$x,$y"
    ($x,$y) = ((3*$y-$x)/2,  # rotate -120;
               ($x+$y)/-2);
    ### level rotate to: "$x,$y"

    foreach my $side (0 .. 5) {
      ### try: "level=$level side=$side  $x,$y"
      if (defined (my $n = _xy_to_n_in_level($x,$y,$level))) {
        return ($side+3)*3**$level + $n - 2;
      }
      $x -= $xend;
      $y -= $yend;
      ### subtract to: "$x,$y"
      ($x,$y) = (($x+3*$y)/2,   # rotate -60
                 ($y-$x)/2);

    }
  }
  return undef;
}

sub _xy_to_n_in_level {
  my ($x, $y, $level) = @_;

  _ends_for_level($level);
  my @pending_n = (0);
  my @pending_x = ($x);
  my @pending_y = ($y);
  my @pending_level = ($level);

  while (@pending_n) {
    my $n = pop @pending_n;
    $x = pop @pending_x;
    $y = pop @pending_y;
    $level = pop @pending_level;
    ### consider: "$x,$y  n=$n level=$level"

    if ($level == 0) {
      if ($x == 0 && $y == 0) {
        return $n;
      }
      ### level=0 and not 0,0
      next;
    }
    if (($x*$x+3*$y*$y) > $_hypotend[$level] * 1.1) {
      ### radius out of range: ($x*$x+3*$y*$y)." cf end ".$_hypotend[$level]
      next;
    }

    $level--;
    $n *= 3;
    my $xend = $_xend[$level];
    my $yend = $_yend[$level];
    ### descend: "end=$xend,$yend on level=$level"

    # digit 0
    push @pending_n, $n;
    push @pending_x, $x;
    push @pending_y, $y;
    push @pending_level, $level;
    ### push: "$x,$y  digit=0"

    # digit 1
    $x -= $xend;
    $y -= $yend;
    ($x,$y) = (($x+3*$y)/2,   # rotate -60
               ($y-$x)/2);
    push @pending_n, $n + 1;
    push @pending_x, $x;
    push @pending_y, $y;
    push @pending_level, $level;
    ### push: "$x,$y  digit=1"

    # digit 2
    $x -= $xend;
    $y -= $yend;
    ($x,$y) = (($x-3*$y)/2,   # rotate +60
               ($x+$y)/2);
    push @pending_n, $n + 2;
    push @pending_x, $x;
    push @pending_y, $y;
    push @pending_level, $level;
    ### push: "$x,$y  digit=2"
  }

  return undef;
}

# Each
#           *---
#          /
#      ---*
# is width=5 heightflat=1 is
#     hypot^2 = 5*5 + 3 * 1*1
#             = 25+3
#             = 28
#     hypot = 2*sqrt(7)
#
# comes in closer to
#     level=1   n=9,x=2,y=2  is hypot=sqrt(2*2+3*2*2) = sqrt(16) = 4
#     level=2   n=31,x=2,y=6 is hypot=sqrt(2*2+3*6*6) = sqrt(112) = sqrt(7)*4
# so
#     radius = 4 * sqrt(7)^(level-1)
#     radius/4 = sqrt(7)^(level-1)
#     level-1 = log(radius/4) / log(sqrt(7))
#     level = log(radius/4) / log(sqrt(7)) + 1
#
# Or
#     level=1   n=9,x=2,y=2  is h=2*2+3*2*2 = 16
#     level=2   n=31,x=2,y=6 is h=2*2+3*6*6 = 112 = 7*16
#     h = 16 * 7^(level-1)
#     h/16 = 7^(level-1)
#     level-1 = log(h/16) / log(7)
#     level = log(h/16) / log(7) + 1
#
# is the next outer level, so high covering is the end of the previous
# level,
#
# Nstart(level) - 1 = 3^(level+2) - 2 - 1
#                   = 3^(level+2) - 3
#
# not exact
sub rect_to_n_range {
  my ($self, $x1,$y1, $x2,$y2) = @_;
  $y1 *= sqrt(3);
  $y2 *= sqrt(3);
  my ($r_lo, $r_hi) = Math::PlanePath::SacksSpiral::_rect_to_radius_range
    ($x1,$y1, $x2,$y2);
  $r_hi *= 2;
  my $level_plus_1 = ceil( log(max(1,$r_hi/4)) / log(sqrt(7)) ) + 2;
  return (1, 3**$level_plus_1 - 3);
}

1;
__END__

=for stopwords eg Ryde Gosper Nstart wiggliness versa PlanePath Math-PlanePath

=head1 NAME

Math::PlanePath::GosperIslands -- concentric Gosper islands

=head1 SYNOPSIS

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

=head1 DESCRIPTION

X<Gosper, William>This path is integer versions of the Gosper island at
successive levels, arranged as concentric rings on a triangular lattice (see
L<Math::PlanePath/Triangular Lattice>).  Each island is the outline of a
self-similar tiling of the plane by hexagons, and the sides are self-similar
expansions of line segments

          35----34                                           8
         /        \
    ..-36          33----32          29----28                7
                           \        /        \
                            31----30          27----26       6
                                                      \
                                                       25    5

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




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

=head2 Hexagon Replications

The islands can be thought of as a self-similar tiling of the plane by
hexagonal shapes.  The innermost hexagon N=1 to N=6 is replicated six times
to make the next outline N=7 to N=24.

                *---*
               /     \
          *---*       *---*
         /     \     /     \
        *       *---*       *
         \     /     \     /
          *---*       *---*
         /     \     /     \
        *       *---*       *
         \     /     \     /
          *---*       *---*
               \     /
                *---*

Then that shape is in turn replicated six times around itself to make the
next level.


                        *---E
                       /     \
                  *---*       *---*       *---*
                 /                 \     /     \
                *                   *---*       *---*
                 \                 /                 \
                  *               *                   D
                 /                 \                 /
            *---*                   *               *
           /     \                 /                 \
      *---*       *---*       *---*                   *
     /                 \     /     \                 /
    *                   *---*       *---*       *---*
     \                 /                 \     /     \
      *               *                   C---*       *---*
     /                 \                 /                 \
    *                   *       O       *                   *
     \                 /                 \                 /
      *---*       *---*                   *               *
           \     /     \                 /                 \
            *---*       *---*       *---*                   *
           /                 \     /     \                 /
          *                   *---*       *---*       *---*
           \                 /                 \     /
            *               *                   *---*
           /                 \                 /
          *                   *               *
           \                 /                 \
            *---*       *---*                   *
                 \     /     \                 /
                  *---*       *---*       *---*
                                   \     /
                                    *---*

The shapes here and at higher level are like hexagons with wiggly sides.
The sides are symmetric, so they mate on opposite sides but the join
"corner" is not on the X axis (after the first level).  For example the
point marked "C" (N=7) is above the axis at X=5,Y=1.  The next replication
joins at point "D" (N=25) at X=11,Y=5.

=head2 Side and Radial Lines

The sides at each level is a self-similar line segment expansion,

                                 *---*
      *---*     becomes         /
                           *---*

This expanding side shape is also the radial line or spoke from the origin
out to "corner" join points.  At level 0 they're straight lines,

       ...----*
             / \
            /   \ side
           /     \
          /       \
         O---------*
                  /
                 /

Then at higher levels they're wiggly, such as level 1,

    ...--*
        / \
       *   *---*
        \       \
         *   *---C
        /   /   /
       O---*   ...

Or level 2,

         *---E
      ...   / \
           *   *---*       *---*
            \       \     /     \
             *       *---*       *---*
            /                         \
           *                       *---D
            \                     /   /
             *---*           *---*   ...
                  \         /
                   *       *
                  /         \
                 *           *
                  \         /
                   *   *---C
                  /   /
                 O---*

The lines become ever wigglier at higher levels, and in fact become "S"
shapes with the ends spiralling around and in (and in fact middle sections
likewise S and spiralling, to a lesser extent).

The spiralling means that the X axis is crossed multiple times at higher
levels.  For example in level 11 X>0,Y=0 occurs 22 times between N=965221 and
N=982146.  Likewise on diagonal lines X=Y and X=-Y which are "sixths" of the
initial hexagon.

The self-similar spiralling means the Y axis too is crossed multiple times
at higher levels.  In level 11 again X=0,Y>0 is crossed 7 times between
N=1233212 and N=1236579.  (Those N's are bigger than the X axis crossing,
because the Nstart position at level 11 has rotated around some 210 degrees
to just under the negative X axis.)

In general any radial straight line is crossed many times way eventually.

=head2 Level Ranges

Counting the inner hexagon as level=0, the side length and whole ring is

    sidelen = 3^level
    ringlen = 6 * 3^level

The starting N for each level is the total points preceding it, so

    Nstart = 1 + ringlen(0) + ... + ringlen(level-1)
           = 3^(level+1) - 2

For example level=2 starts at Nstart=3^3-2=25.

The way the side/radial lines expand as described above makes the Nstart
position rotate around at each level.  N=7 is at X=5,Y=1 which is angle

    angle = arctan(1*sqrt(3) / 5)
          = 19.106.. degrees

The sqrt(3) factor as usual turns the flattened integer X,Y coordinates into
proper equilateral triangles.  The further levels are then multiples of that
angle.  For example N=25 at X=11,Y=5 is 2*angle, or N=79 at X=20,Y=18 at
3*angle.

The N=7 which is the first radial replication at X=5,Y=1, scaled to unit
sided equilateral triangles, has distance from the origin

    d1 = hypot(5, 1*sqrt(3)) / 2
       = sqrt(7)

The subsequent levels are powers of that sqrt(7),

    Xstart,Ystart of the Nstart(level) position

    d = hypot(Xstart,Ystart*sqrt(3))/2
      = sqrt(7) ^ level

This multiple of the angle and powering of the radius means the Nstart
points are on a logarithmic spiral.

=head2 Fractal Island

The Gosper island is usually conceived as a fractal, with the initial
hexagon in a fixed position and the sides having the line segment
substitution described above, for ever finer levels of "S" spiralling
wiggliness.  The code here can be used for that by rotating the Nstart
position back to the X axis and scaling down to a desired unit radius.

    Xstart,Ystart of the Nstart(level) position

    scale factor = 0.5 / hypot(Ystart*sqrt(3), Xstart)
    rotate angle = - atan2 (Ystart*sqrt(3), Xstart)

This scale and rotate puts the Nstart point at X=1,Y=0 and further points of
the ring around from that.  Remember the sqrt(3) factor on Y for all points
to turn the integer coordinates into proper equilateral triangles.

Notice the line segment substitution doesn't change the area of the initial
hexagon.  Effectively (and not to scale),

                                 *
                                / \ 
    *-------*    becomes   *   /   *
                            \ /   
                             *

So the area lost below is gained above (or vice versa).  The result is a
line of ever greater length enclosing an unchanging area.

=head1 FUNCTIONS

See L<Math::PlanePath/FUNCTIONS> for behaviour common to all path classes.

=over 4

=item C<$path = Math::PlanePath::GosperIslands-E<gt>new ()>

Create and return a new path object.

=item C<($x,$y) = $path-E<gt>n_to_xy ($n)>

Return the X,Y coordinates of point number C<$n> on the path.  Points begin
at 1 and if C<$n E<lt> 0> then the return is an empty list.

=back

=head1 SEE ALSO

L<Math::PlanePath>,
L<Math::PlanePath::KochSnowflakes>,
L<Math::PlanePath::GosperSide>

=head1 HOME PAGE

L<http://user42.tuxfamily.org/math-planepath/index.html>

=head1 LICENSE

Copyright 2011, 2012, 2013 Kevin Ryde

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/>.

=cut