2D Grid Math Help

Hey Everybody,

I am using the 2D Grid Macro to create an array of 3D objects.
The grid outputs:

  • Current point index
  • Total points
  • X row (the total number of X instances)
  • Y row (the total number of Y instances)

My grid is always equal so 6x6 / 10x10 and so on.
I feed each instance those variables as they are created.

I want to calculate the X indicator and Y indicator for each instance, from this data.
I got a bit confused with the math here.

Basically, using the array index to find out where is it located in the grid.

For example, in a 4x4 grid.
Instance number 7, is X position 3 / Y position 2.

I tried various things online but couldn’t find the right solution.
Anybody has a working method for extracting that?

Thanks in advance!

Elad

You could use modulo % to get row/col. For example:

  • to get divisor since its cubic just square root the size of the array.
  • if you want to know where a specific instance is in the grid: get its index within the array as the dividend % by the divider and return value will be X (row), remainder will be Y (column).

So on a 10x10, instance #77 % 10 will be return value 7 and remainder 7; on a 6x6 grid, instance 18 % 6 will give return value 3, remainder 0.

You might need to + 1 depending on what you want.

Sorry for the double posts,

Turns out I was wrong and the Macro does give the X/Y exact positions - but thank you so much for teaching me about the other method!

1 Like