Cartesian coordinates of the points on the plane in the same order as the Ulam Spiral

1.2k Views Asked by At

I'm messing around with doing a visualization that has nothing to do with the primes and in order to execute it correctly I need an ordered list of all point in the order that the Ulam Spiral crosses them. I've tried some of my work but have only run in to abundantly complicated paths to solution. Also is there a name for looking for pattern that generally occur in spiral, whether they are related to primes or not?

E.g.: Starting with this image:

enter image description here

if $1$ is at the origin, then the list would be as follows: $$(0,0),(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1),‌​(2,-1),(2,0),...$$

2

There are 2 best solutions below

4
On BEST ANSWER

You are lucky because it seems that a very similar pair of sequences is already at OEIS.

The $x$-coordinates are sequence A174344 ("List of $x$-coordinates of point moving in clockwise spiral") and $y$-coordinates ("List of $y$-coordinates of point moving in clockwise spiral") are sequence A268038.

List of $x$-coordinates of point moving in clockwise spiral.

$$0, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, -1, -2, -3, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -2, \cdots$$

List of $y$-coordinates of point moving in clockwise spiral.

$$0, 0, -1, -1, -1, 0, 1, 1, 1, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -2, -1, 0, 1, 2, 3, 4, 4, 4, \cdots$$

In the referred OEIS pages there are formulas to calculate each sequence of coordinates.

1
On

A piecewise, explicit function is provided by the accepted answer of a similar question.