Drawing circumference issue

88 Views Asked by At

I'm a developer, and I'm developing an app on Google Maps. At the moment, I'm trying to draw a circle on the map.

For getting all the points I need, I'm using the following formula:

\begin{equation} y=y_c\pm\sqrt{r^2-(x-x_c)^2} \end{equation}

but I get an ellipse, not a circle.

enter image description here

Did I mistake the formula?

Or I need to search the error in my code?

Thanks in advance.

UPDATE I found that I have to draw an ellipse, because of the different axis scale. At the moment I can find four correct points (north, east, south, west).

3

There are 3 best solutions below

1
On

The general equation of an circle is $(x-x_c)^2+(y-y_c)^2=r^2$. This can be rewritten to your equation. I think that there is a mistake in your code. In particular, check whether you don't divide of multiply $x$ by anything, that will result in an ellipse.

0
On

One way to accidentally get an ellipse instead of a circle is to have different length scales on the two coordinate axes.

0
On

Google Maps uses the Mercator projection system, which distorts the coordinates vertically, proportionally to the secant of the latitude.

On the picture I measure that the ellipse is about $482\times689$ pixels, i.e. has an aspect ratio of $0.7$, which corresponds to a latitude of $45.6°$. The true latitude of Milano is $45°28'=45.46°$. Not so bad...