Usually I tell people who seem to think they need to get to Calculus III before they can program not to fret, but I am going to have to go ahead and suggest a couple more math classes to you, or at least a few hours of online tutorials.
If you know (x,y) is the center of an N by M square and you know which square (x,y) resides, you can certainly use basic algebra to calculate the absolute position of (x,y).
Example:
Code:
In my example I am going to use some ascii art, and ignore your duplicate "5" square.
Lets say you p2 is in some known relative location in square number 15.
I hate 2d arrays so we can see that each row is 5N wide, thus a the row is mathematically,
3M * 5N
From there you can add the column which you desire, which in this case is the fourth one
4N
So we know you are dealing with square 3M * 5N + 4N (yes this could be simplified further, but we needn't mess with that now).
That should get you started. On an important note: do not forget that when you are programming your geometry will be going the opposite direction and your counting will always be starting with 0.