Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a developer very bad in math, and I got a problem that I'm not able to solve.

I got a grid each cell got a position X and Y like shown in the picture below


Actually I got the red coordinates, I need the green ones...
My cells are in diagonal so it takes the diagonal line as center.

If I do X - Y it would be good for the first col, but the second one will have 1 too much.

I don't have many clues

Sorry if I put the wrong tags but I don't have many ideas of where to put it.

Thank you for your help.

share|cite|improve this question
up vote 2 down vote accepted

Call the red coordinates $X$ and $Y$, and the green coordinates $X'$ and $Y'$. Then

$$X' = (Y+X)/2,$$

$$Y' = (Y-X)/2.$$

You can think of this as the result of applying a rotation of $45^\circ$ clockwise to the vector $(X,Y)$, then normalizing the result.

share|cite|improve this answer
Wow thank you ! Sorry for my late reply but I needed to go somewhere. Thank you very much – Shadowbob May 12 '12 at 8:16
You're very welcome, @Shadowbob. – Antonio Vargas May 12 '12 at 14:52
And now to have the opposite ? – Shadowbob May 13 '12 at 10:42
Oh I found it X' - Y' = X and X' + Y' = Y – Shadowbob May 13 '12 at 11:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.