Math-PlanePath
view release on metacpan or search on metacpan
devel/lib/Math/PlanePath/SquaRecurve.pm view on Meta::CPAN
=over 4
=item C<$path = Math::PlanePath::SquaRecurve-E<gt>new ()>
=item C<$path = Math::PlanePath::SquaRecurve-E<gt>new (radix =E<gt> $r)>
Create and return a new path object.
The optional C<radix> parameter gives the base for digit splitting. The
default is ternary, C<radix =E<gt> 3>.
=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 0 and if C<$n E<lt> 0> then the return is an empty list.
Fractional positions give an X,Y position along a straight line between the
integer positions.
=back
=head1 FORMULAS
=head2 N to Turn
The curve turns left or right 90 degrees at each point N E<gt>= 1. The turn
is 90 degrees
turn(N) = 90 degrees * (-1)^(N + number of low ternary 0s of N)
= -1,1,1,1,-1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,-1,1
=cut
# GP-DEFINE turn(n) = (-1)^(n + valuation(n,3));
# GP-Test vector(18,n, turn(n)) == \
# GP-Test [-1,1, 1, 1,-1, -1, -1,1,-1,1,-1, -1, -1,1,1,1,-1,1]
# not in OEIS: -1,1,1,1,-1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,-1,1
# not in OEIS: 1,-1,-1,-1,1,1,1,-1,1,-1,1,1,1,-1,-1,-1,1,-1 \\ negated
# not in OEIS: 0,1,1,1,0,0,0,1,0,1,0,0,0,1,1,1,0,1,0,1,1,1,0,0,0,1,1,1,0,0 \\ ones
# not in OEIS: 1,0,0,0,1,1,1,0,1,0,1,1,1,0,0,0,1,0 \\ zeros
# GP-Test vector(900,n, turn(3*n)) == \
# GP-Test vector(900,n, -turn(n))
# GP-Test vector(900,n, turn(3*n+1)) == \
# GP-Test vector(900,n, -(-1)^n)
# GP-Test vector(900,n, turn(3*n+2)) == \
# GP-Test vector(900,n, (-1)^n)
# vector(25,n, (-1)^valuation(n,3))
# not in OEIS: 1,1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,1,1,-1,1
# vector(100,n, valuation(n,3)%2)
# A182581 num ternary low 0s mod 2
=pod
The power of -1 means left or right flip for each low ternary 0 of N, and
flip again if N is odd. Odd N is an odd number of ternary 1 digits.
This formula follows from the turns in a new low base-9 digit. The start
and end of the base figure are in the same directions so the turns at 9*N
are unchanged. Then 9*N+r goes as r in the base figure, but flipped
LE<lt>-E<gt>R when N odd since blocks are mirrored alternately.
turn(9N) = turn(N)
turn(9N+r) = turn(r)*(-1)^N for 1 <= r <= 8
=cut
# GP-Test vector(900,n, turn(9*n)) == \
# GP-Test vector(900,n, turn(n))
# GP-Test matrix(90,8,n,r, turn(9*n+r)) == \
# GP-Test matrix(90,8,n,r, turn(r)*(-1)^n)
=pod
Just in terms of base 3, a single new low ternary digit is a transpose of
what's above, and the base figure turns r=1,2 and LE<lt>-E<gt>R when N above
is odd again.
The same for any odd radix.
=head1 SEE ALSO
L<Math::PlanePath>,
L<Math::PlanePath::PeanoCurve>
=over
DOI 10.1007/BF01199438
http://www.springerlink.com/content/w232301n53960133/
=back
=head1 HOME PAGE
L<http://user42.tuxfamily.org/math-planepath/index.html>
=head1 LICENSE
Copyright 2019, 2020 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/>.
=cut
( run in 0.742 second using v1.01-cache-2.11-cpan-df04353d9ac )