Converting from Polar Coordinate to Cartesian Coordinate

Basically there are two ways to know where are we on a graph or a map:

  • cartesian coordinates
  • polar coordinates

Cartesian coordinates tell us that “how far along” and “how far up” we are:

Cartesian Coordinates

Polar coordinates tell us that “how far away” at “what angle” we are:

Polar Coordinates

Both points to the same point.

To convert from Polar to Cartesian there is a simple method:

  • x = r × cos( θ )
  • y = r × sin( θ )

Where r is (now) 13, and θ is (now) 22.6°

To get the exact point in C#, let’s create this simple static method, within a static class:

public static class Converters
{
    public static Point PolarToCartesian(double angle, double radius)
    {
        double angleRad = (Math.PI / 180.0) * (angle - 90);
        double x = radius * Math.Cos(angleRad);
        double y = radius * Math.Sin(angleRad);
        return new Point(x, y);
    }
}

This converter could be useful even if you create your own control that’s rounded shaped.