I have a 6x6 grid, and in its first cell (row 1, column 1), its value is (-3, 2) and on its last cell (row 6, cell 6), its value is (2, -3).

Another values inside this grid are:

$(x_0, y_0) => (x_1, y_1)$

(1, 2) => (-2, 2)
(1, 3) => (-1, 2)
(1, 4) => (0, 2)
(1, 5) => (1, 2)
(1, 6) => (2, 2)
(2, 1) => (-3, 1)
(3, 1) => (-3, 0)
(4, 1) => (-3, -1)
(5, 1) => (-3, -2)
(6, 1) => (-3, -3)

$(x_0, y_0)$ are the row, column of the grid, and $(x_1, y_1)$ are the values on each cell.

Is there any formula to translate $(x_0, y_0)$ into $(x_1, y_1)$?

Maybe the grid will be bigger than 6x6 (or smaller...). All the grids will be nxn., and the first cell will be always (-n/2, n/2 - 1).

  • $\begingroup$ What are the values at the other cells in the grid? $\endgroup$ – saulspatz Jul 11 '19 at 20:15
  • $\begingroup$ I don't quite understand what you mean or what you want. I think $(x_0, y_0)$ are the coordinates of a cell, and $(x_1, y_1)$ the value there. If so, then just make the $x$ values constant on the columns and the $y$ values constant on the rows. If that's not what you want, please edit to clarify. Perhaps tell us where the problem comes from. $\endgroup$ – Ethan Bolker Jul 11 '19 at 20:20
  • $\begingroup$ Can $n$ be odd? If so, do we round $n/2$ up, round it down, use the exact value (not an integer), or something else? $\endgroup$ – David K Jul 12 '19 at 4:06
  • $\begingroup$ No, $n$ can not be odd. $\endgroup$ – VansFannel Jul 12 '19 at 5:13

Based on the data you provided, for the $6\times 6$ grid the formulas would be \begin{align} x_1 &= y_0 - 4, \\ y_1 &= 3 - x_0. \end{align}

Based on the information that the grid is always square and that for an $n\times n$ grid, the cell at $x_0=y_0=1$ has $x_1 = -\frac n2$ and $y_1 = \frac n2 - 1,$ the general formulas are \begin{align} x_1 &= y_0 - \left(\frac n2 + 1\right), \\ y_1 &= \frac n2 - x_0. \end{align}

Note that $\frac n2$ is not an integer if $n$ is odd. If $n$ is always even, however, then $x_1$ and $y_1$ will be integers.

The clues that lead to these formulas are that $x_1$ is constant when $y_0$ is constant, $y_1$ is constant when $x_0$ is constant, $x_1$ increases when $y_0$ increases, and $y_1$ decreases when $x_0$ increases. This tells us we need formulas $x_1 = y_0 + a$ and $y_1 = b - x_0$ for some constants $a$ and $b.$ Then use the values of $x_1$ and $y_1$ when $x_0=y_0=1$ to figure out what $a$ and $b$ must be.

  • $\begingroup$ All the grids will be squares. $\endgroup$ – VansFannel Jul 11 '19 at 20:31
  • $\begingroup$ Thanks a lot for answer and explanations. Maybe, it could be generalized if we know the value inside the first cell, by the way the first cell is (1, 1); and we know the number of rows and columns of the grid (the number of rows doesn't have to be the same as the number of columns). But I think this is another answer. $\endgroup$ – VansFannel Jul 12 '19 at 12:30

Your Answer

