For clarity, let the “hexagonal” coordinates be (r,g,b) where r, g, and b are the red, green, and blue coordinates, respectively. The coordinates (r,g,b) and (x,y) are related by the following:
y = 3/2 * s * b
b = 2/3 * y / s
x = sqrt(3) * s * ( b/2 + r)
x = - sqrt(3) * s * ( b/2 + g )
r = (sqrt(3)/3 * x - y/3 ) / s
g = -(sqrt(3)/3 * x + y/3 ) / s
r + b + g = 0
Derivation:
-
I first noticed that any horizontal row of hexagons (which should have a constant
y-coordinate) had a constantbcoordinate, soydepended only onb. Each hexagon can be broken into six equilateral triangles with sides of lengths; the centers of the hexagons in one row are one and a half side-lengths above/below the centers in the next row (or, perhaps easier to see, the centers in one row are 3 side lengths above/below the centers two rows away), so for each change of1inb,ychanges3/2 * s, giving the first formula. Solving forbin terms ofygives the second formula. -
The hexagons with a given
rcoordinate all have centers on a line perpendicular to the r axis at the point on theraxis that is3/2 * sfrom the origin (similar to the above derivation ofyin terms ofb). Theraxis has slope-sqrt(3)/3, so a line perpendicular to it has slopesqrt(3); the point on theraxis and on the line has coordinates(3sqrt(3)/4 * s * r, -3/4 * s * r); so an equation inxandyfor the line containing the centers of the hexagons withr-coordinaterisy + 3/4 * s * r = sqrt(3) * (x - 3sqrt(3)/4 * s * r). Substituting foryusing the first formula and solving forxgives the second formula. (This is not how I actually derived this one, but my derivation was graphical with lots of trial and error and this algebraic method is more concise.) -
The set of hexagons with a given
rcoordinate is the horizontal reflection of the set of hexagons with that g coordinate, so whatever the formula is for thexcoordinate in terms ofrandb, thexcoordinate for that formula withgin place ofrwill be the opposite. This gives the third formula. -
The fourth and fifth formulas come from substituting the second formula for
band solving forrorgin terms ofxandy. -
The final formula came from observation, verified by algebra with the earlier formulas.