# Calculating coordinates of corners of polygon

In the image below, I have a Google Earth-based application I am working on and a specific requirement is to calculate the bounds of a drawn polygon given the center($P$) coordinates $(a,b)$, radius($r$) and coordinates of one point $(x,y)$. I also have the bearing (angle) of the radius between the center coordinate and the point $(x,y)$. I need to figure out how to calculate the coordinates of the other points $I$, $J$, and $K$. I will limit the question to just a rectangle for simplicity's sake.

I know how to use Pythagoras' theorem and some basic algebra to calculate the values I want given a polygon that is perfectly level or at a 90 degree angle to the equator, but the bearing thrown into the mix is giving me a very hard time. I know p and q seem to be perpendicular to the equator (bearing 0 degrees) in the example, but it's actually 0.6* degrees and may be any value between 0 and 359. The case with a square is quite simple, you just need to rotate point q around center p. Formula for rotation is:

$x' = (x-a)*cos\alpha - (y-b)*sin\alpha + a$,

$y' = (x-a)*sin\alpha + (y-b)*cos\alpha + b$;

where $(x,y)$ - old coordinates, $(x', y')$ - new coordinates, $(a,b)$ - center of rotation, $\alpha$ - degree of rotation.

In your case, if y axis is bottom-up:

$i = ( -y + b + a, x - a + b )$

$j = ( -x + 2a, -y + 2b )$

$k = ( y - b + a, -x + a + b )$

• Well, it certainly looks familiar. Thanks. – Captain Kenpachi May 1 '14 at 9:01