Wikipedia says about Polar Coordinates:
In mathematics, the polar coordinate system is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a reference point and an angle from a reference direction.
This seems perfect for describing hexagonal grids. Take the following hexagonal grid for example:
A B C D E F G H I J K L M N O P Q R S
Our reference point will be the center of the hexagon ('J'), and our reference angle will be to the top left corner of the hexagon ('A'). However, we'll describe the angle in terms of the number of clockwise steps around the outside of the hexagon from this point, not in angles. So we'll call it "Step number" instead of angle.
For example, 'C' is at (2, 2) because it has a radius of 2 (since it is two rings away from the center, 'J'), and an step number of 2 (2 clockwise steps forward from 'A'). Similarly, 'O' is at (1, 3), because it is one ring away from the center, and three clockwise steps forward from 'E' (which is on the reference angle).
For completeness, 'J' is at (0, 0), since you need 0 steps out and 0 steps clockwise to reach it.
Now, you can also describe a hexagonal with Cartesian Coordinates, but because of the offset this is a little weird. Just like with our polar coordinates, we will put the center at (0, 0). Each space takes up a coordinate also, so 'K' is at (2, 0), not (1, 0). This would put 'A' at (-2, 2), and 'O' at (1, -1).
Given polar hexagonal coordinates, output the same coordinates in Cartesian coordinates. You may take these coords, and the output the answer in any reasonable format. This means that you may reverse the order of the inputs if you like. This also means you could output the coords as (Y, X), but if you do, please mention this in your answer to avoid confusion.
You do not have to handle negative radii, but you may get negative angles, or angles that go more than a full revolution around the hexagon. For example, you may receive (1, 10), or (1, -2) as input. These would both correspond to 'N' in our previous hexagon. You do not have to handle non-integers for input.
#Polar #Cartesian (0, 0) (0, 0) (1, 2) (2, 0) (6, 0) (-6, 6) (2, -3) (-3, -1) (4, 23), (-5, 3) (5, -3), (-8, 2) (10, 50), (-20, 0) (6, 10), (10, 2) (8, 28), (0, -8) (8, -20), (0, -8)