Prev: Unsolvability of the Entscheidungsproblem as a Corollary ofGödel’s 2nd Theorem
Next: Deja Vu Divisors -- Game
From: Ludovicus on 1 Jun 2010 16:10 Is there an algorithm to transform the numbers of an Ulam spiral to its integer cartesian coordinates? Example: The origin of coordinates is the same zero of spiral. ________________________________________ | | | | | | | 16 | 15 | 14 | 13 | 12 | | | | | | | --------------------------------------------------------------------- | | | | | | | 17 | 4 | 3 | 2 | 11 | | | | | | | --------------------------------------------------------------------- | | | | | | | 18 | 5 | 0 | 1 | 10 | | | | | | | --------------------------------------------------------------------- | | | | | | | 19 | 6 | 7 | 8 | 9 | | | | | | | ---------------------------------------------------------------------
From: Ludovicus on 1 Jun 2010 16:40 On Jun 1, 4:10 pm, Ludovicus <luir...(a)yahoo.com> wrote: > Is there an algorithm to transform the numbers of an Ulam > spiral to its integer cartesian coordinates? Example: > The origin of coordinates is the same zero of spiral. > > _______________________________________________________________________ > | | | | | | > | | | | | | > | 16 | 15 | 14 | 13 | 12 | > | | | | | | > | | | | | | > --------------------------------------------------------------------- > | | | | | | > | | | | | | > | 17 | 4 | 3 | 2 | 11 | > | | | | | | > | | | | | | > -----------------------------------------------------------------------| > | | | | | | > | | | | | | > | 18 | 5 | 0 | 1 | 10 | > | | | | | | > | | | | | | > ----------------------------------------------------------------------- > | | | | | | > | | | | | | > | 19 | 6 | 7 | 8 | 9 | > | | | | | | > | | | | | | > -----------------------------------------------------------------------| > | | | | | | > | | | | | | > | 20 | 21 | 22 | 23 | 24 | > | | | | | | > | | | | | | > ---------------------------------------------------------------------
From: Rob Johnson on 3 Jun 2010 15:10
In article <1b6fe94c-e0d4-4d52-a692-d11304ada311(a)o4g2000vbo.googlegroups.com>, Ludovicus <luiroto(a)yahoo.com> wrote: >On Jun 1, 4:10 pm, Ludovicus <luir...(a)yahoo.com> wrote: >> Is there an algorithm to transform the numbers of an Ulam >> spiral to its integer cartesian coordinates? Example: >> The origin of coordinates is the same zero of spiral. >> >> _______________________________________________________________________ >> | | | | | | >> | | | | | | >> | 16 | 15 | 14 | 13 | 12 | >> | | | | | | >> | | | | | | >> --------------------------------------------------------------------- >> | | | | | | >> | | | | | | >> | 17 | 4 | 3 | 2 | 11 | >> | | | | | | >> | | | | | | >> -----------------------------------------------------------------------| >> | | | | | | >> | | | | | | >> | 18 | 5 | 0 | 1 | 10 | >> | | | | | | >> | | | | | | >> ----------------------------------------------------------------------- >> | | | | | | >> | | | | | | >> | 19 | 6 | 7 | 8 | 9 | >> | | | | | | >> | | | | | | >> -----------------------------------------------------------------------| >> | | | | | | >> | | | | | | >> | 20 | 21 | 22 | 23 | 24 | >> | | | | | | >> | | | | | | >> --------------------------------------------------------------------- Index to position ----------------- n -> (x,y) 0 -> (0,0) for n > 0, sqrt(n)+1 m = floor( --------- ) 2 k = n - 4m(m-1) 1 <= k <= 2m -> (x,y) = (m,k-m) 2m <= k <= 4m -> (x,y) = (3m-k,m) 4m <= k <= 6m -> (x,y) = (-m,5m-k) 6m <= k <= 8m -> (x,y) = (k-7m,-m) Position to index ----------------- (x,y) -> n m = max(|x|,|y|) x = m -> n = 4m(m-1) + m + y except if y = -m y = m -> n = 4m(m-1) + 3m - x x = -m -> n = 4m(m-1) + 5m - y y = -m -> n = 4m(m-1) + 7m + x Rob Johnson <rob(a)trash.whim.org> take out the trash before replying to view any ASCII art, display article in a monospaced font |