I'm working on a project where we need to be able to bind a number to every existing X and Y coordinate

I'm working on a project where we need to be able to bind a number to every existing X and Y coordinate.

We thought about doing it this way but I have no idea how to handle making a formula out of this. Please Sup Forums I have tried everything.

Other urls found in this thread:

en.wikipedia.org/wiki/Spiral
en.wikipedia.org/wiki/Pairing_function
twitter.com/NSFWRedditVideo

Could you be more accurate?

I want to have a function that I can say;

int numberFromSpiral(int y, int x){
//Do shit
return TheNumber
}

If I put in the y and x it just returns the number on the grid on the same place. (from the spiral)

The number in the square counts for the points in the left under corner of its containing box.
so
(0.0) = 0;
and (0.-1) = 1;
and (1.1) = 4;

"What are index shifted double arrays?" for $50 Alex.

You want a mapping from Z^2 to N?

en.wikipedia.org/wiki/Spiral

...

>//Do shit

I did shit, but the only output is in pic related

bump, cause idk how to do this either, I'm trying here on my end

```5.1 Introduction
Suppose that you need to find the sum of integers from 1 to 10, from 20 to 30, and from 35
to 45, respectively. You may write the code as follows:
int sum = 0

So, let's say you start from 1, to make things simpler

Notice that if you do start counting from 1, the squares of number are always on a diagonal from the origin, where 8, 24, 48 are on your picture

Some thoughts that will get you there:

After you put a 1 square on, this spiral creates every subsequent square using only 2 lines.

You can find out the maximal square containing a coordinate from its taxicab distance and which quadrant it's in.

Once you know the maximal square containing a coordinate, you can easily find out the line containing that coordinate.

From this, you can get the number.

That function is not even possible it seems

The function this way is also an option if people do know that one?

|
|
16 15 14 13 12
17 4 3 2 11
-- 18 5 0 1 10 --- x
19 6 7 8 9
20 21 22 23 24
|
|

just read this post and give it some thought:
We're not going to spoonfeed you.

19/6/17
in exactly 7 days from now

>illuminati confirmed?

|
|
16 15 14 13 12
17 4 3 2 11
-- 18 5 0 1 10 --- x
19 6 7 8 9
20 21 22 23 24
|
|

Then I apparently don't have the brain power to put it all together.

I know how much numbers there are in a row per height with X * 2 + 1. And I know that the diagonals are the power of 2.

But that's all my brain gets out of me.

Seems like your "graph" is really poorly defined around the origin, why do the numbers work in a spiral to the right first, your first 4 numbers 0123 should create a 2x2 square, your for 16 numbers should create a 4x4 square, your first 2^2n numbers should create a 2nx2n square etc, see what I'm getting at, define ur grid better and everything falls into place

Okay op,
let x,y be the integer coordinates of your point

if y>0:
move to the right until you get to the plane bisector, count how much you moved, add to the square of the x coordinate of the point in the diagonal

this is very incomplete and wrong, but I'm working on the strategy and don't want this to be pruned

haha I remember doing this with prime numbers as an arts project when I was 16

I used a direction arrow which increases by 1 every second time it changes direction, maybe this helps

0-> 1 go DOWN length 1
1 -> 2 go RIGHT length 1
2 - 4 go UP length 2
4 -> 6 go LEFT length 2
6 -> 9 go DOWN length 3
ect... maybe this helps

actually, I did exactly this, but then colorcoded the numbers if they were prime

I think OP want's the inverse function of what you said, he wants (x,y)->(n)

poor definition, he wants to bind a number to every coordinate, not bind a coordinate to every number
I thought his inputs were the numbers?

My english is not the clearest most of the time.

I want to be able to give the X and Y and get the number on the grid.

Everyone knows how a for-loop works.

Ah, I'm sorry, this is easier.
's way is pretty good

Set up some vector arithmetic, store them in a list, then add all of them up.

not sure if OP is allowed to work off a list, but this probably works

just start with 0/0 as 0
then increase y by 1, you get 0/1 as 1
increase x by 1, you get 1/1 as 2
decrease y by 1, you get 1/0 as 3
decrease y by 1 again, you get 1/-1 as 4

let this run until you arrive at the number you think is high enough, then you get the list which you can look up the x/y coordinates

might be a wonky solution, but hey - its something!

I'm using top left as 0/0, old habit. probably not correct in your example

...

Not OP but that's probably what he wants

Yeah I don't even know what that means, but If you think I want that I want that

Are you trying to create an Ulam spiral?

What the fuck OP I"ve been trying to find the exact same thing a few months ago. I found a formula for it but I can't find my sheet anymore (I only remember that it contained a sum of squares). Could you post some address where I could contact you if I find my sheet ?

>Ulam spiral
Looks like something I have now. But I want it reversed. I want to be able to give an X and Y and get the number in the spiral back.

How would I go posting contact information on Sup Forums?

just run through it and create a list with coordinates and numbers at that coordinate

then you can get the index of X, and use the index to get the coordinates of X in the list

I should comment:
Okay:

We define a dictionary for translating numbers to "vectors", Down, Right, Up, Left
Then I kinda just trusted , then corrected overshoot

You should take those tuples and add them up.

I have no fucking clue:

OP is confused :D

I don't know, you can try creating a fake email address with yopmail for example (I'm taking a dump right now so I'm not on my computer but I'm all yours in 5min)

The main reason I want this is that every X and Y pair are unique and the x and y can be scaled up to no end but it should cost as les processing power for us (especial the lower numbers)

Make a proxy email, then tell the real email in a proxy email...make new email addresses for more proxies. Post one email address here and go about exchanging info

$ cat spiral.c
#include
#include

int spiral(int x, int y) {
if( y >= 0 && y >= abs(x))
return 4*y*y + y - x;
if( x

Ok I'm back. Go to yopmail.com and pick an email address. It doesn't need registration.

Dude! This works perfectly!
I don't know how you did it, but it works like a goddamn charm!

I would buy you a beer or 3, fuck I would buy you some hard liqueur!

>liqueur
are you french ?

I am not. But keep guessing and get disappointed with my english skill related to my countries overall skill.

this maps from coordinates to integers. didn't you want a map from integers to coordinates?

curious why you want this though.

Why is your Y axis horizontal and your X axis vertical?

>curious why you want this though.

Because I don't have any memory to store shit but do have processing power.

i mean why you don't store your data in a standard 2d array or a dictionary?

It needed to be a math equation because I have no memory to store shit on.

Can I ask why do you want to do that ?

are you programming a firmware update for your tamagotchi?

The left hand side operands of the && operator are redundant conditions since an absolute value is necessarily positive. You can remove them.

if it's low level, you could always move the x coordinate into the first n/2 bits and the y coordinate into the remaining bits of your memory space

(OP)

Also, consider using another order than your pic.I suggest using the same order as in Ulam's spiral (e.g. (0, 0) is 0, (0, 1) is 1, (1, 1) is 2) with counter clockwise rotation.

Research exercise for math enthusiasts:

Generalize this spiral to work not only on the integer lattices, but on the entire plane (as in R^2).

herp derp what is a square root

>are you programming a firmware update for your tamagotchi?

Perhaps.

What does the rotation matter?

isn't this the same as finding a bijection from C to R?

>Perhaps.

well send it to me because mine always starved to death. it was very traumatic.

Yes it is. But you have to find the right bijection.

>What does the rotation matter?

It doesn't. It's just for the sake of coherence between different mathematical objects (here, with Ulam's spiral). Also, if you work with continuous spirals (not just integers), complex numbers could be useful, and they use radians to represent rotations (in the exponential form), and radians work counter clockwise starting from the x axis.

math exercises aside, just put the x-coord in the first half of your variable/register and the y-coord in the second. more efficient than the other methods.

you mean it has to be a spiral?

Well it's not a spiral anymore because it's a plane. However, at integer coordinates, you must find the same number as in OP's spiral.

There are probably more than one solution.

radians and distance don't have to be negative so you don't worry about the sign. could probably mash the radians and distance into a real number somehow, like even/odd digit positions. dunno if this is what you mean.

No I meant that radians start (at theta = 0 rad) at the horizontal axis and then rotate counter clockwise. OP's spiral indeed rotates counter clockwise but the first non zero number is at (0, -1) where I think it should be at (1, 0) for coherence matters.

It never fails to amaze me how retarded people are.

Took me a good 3 minutes to figure this out.

no it has to be continuous

differentiable is actually what i meant to ask.

Yes, differentiable at every point.

you could encode the integer part like this poster does
and have the fractional xy sub-coordinates for each 1x1 box stored reversed in the even/odd digits of the non-integer part

no because it has to be differentiable

need a hint

I don't know much more than you. I'm on the problem too and I still haven't figured it out.

en.wikipedia.org/wiki/Pairing_function