# Calculation of Hexagon Coordinates given row and column?

I have the following example image of my hexagon "grid":

Each Hexagon has a column and row. The coordinate system I am choosing for my hex layout is an X,Y coordinate system, with the X coordinates landing across the red lines and the Y coordinates simply equal to the row. In my image I have the X,Y coordinate for each hex displayed in the middle in the middle of the hex.

My Question: Given the row and column of a hex, how do you calculate the X,Y coordinate of the hex (or more simply, how do you calculate the X coordinate, since the Y coord = row number)?

I have tried to come up with various equations that work for each hex but no luck yet. An equation that comes close is:

x = Math.floor(column/2) + (row%2)


But that doesn't satisfy all the hex's. I think I am on the right track.

Also, please assume that the hex grid continues infinitely down and to the right.

-

Observe that if the sum of the row and column (i'm using matrix (row, column) = $(r,c)$ notation) is even, there is a hexagon but if it is odd, there is a common side of two adjacent hexagon.
The new coordinates of the hexagon at $(r,c)$ is $$(x,y)=\left(\cfrac {r+c}{2}\ ,\ r\right) \ \ \ if \ \ \ \ \ r+c \ \ \ \text{ is even }$$
@Jakobud $(r,c)$ is (row, column) and $x=\cfrac{r+c}{2}$. –  user31280 Nov 29 '12 at 21:58
(r+c)/2... geez how did I not see that? Thank you very much! –  Jakobud Nov 29 '12 at 22:06