I’m working with a simple X,Y coordinate system. Either can be positive or negative, and the range is 0 to 400 in all four directions:
-400,400 = top left
400,400 = top right
0,0 = center
-400,-400 = bottom left
400,-400 bottom right
There is a predefined conversion I’m trying to figure out that combines a coordinate pair into a single number. They call this single number Z, despite it not being an actual Z coordinate.
It would be helpful to me if I could convert the X,Y pairs into Z, and vice versa, but this very basic arithmetic is beyond my grasp. Any help would be appreciated.
Here’s some sample values:
X Y Z
---- ---- ------
58 41 288018
59 41 288019
58 40 288819
59 40 288820
-106 -34 347929
-140 -131 425592
-139 -131 425593
-138 -131 425594
-140 -132 426393
-139 -132 426394
-138 -132 426395
-140 -133 427194
-139 -133 427195
-138 -133 427196
I can provide more samples as needed, though I can’t arbitrarily find out the Z for any given X.Y.
Not sure if this is relevant, but the grid is actually a sphere of some kind. (-400,100) directly borders (400,100), for example. This is true in all directions. That means there’s a single 2x2 area with coordinates:
400,-400 (top left of the 2x2)
-400,-400 (top right of the 2x2)
400,400 (bottom left of the 2x2)
-400,400 (bottom right of the 2x2)
EDIT: And no, this is not homework. It’s for a game I play.
Multiplying one number by the range of the other, and adding the other to the result, is the standard way of doing stuff like that. In this case they had to do some adjustments if they only wanted positive numbers. Not sure why they decided to use 400 - y instead of 400 + y, though, that seemed a bit unnecessarily convoluted.