Obtaining the four corner coordinates of a square from the center point. I'm trying to get the corner coordinates of a Square (NOTE, always a square) problematically. (EX: With a formula) and I'm having a hard time adding this into my computer application. Here's an illustration of what I'm trying to do:
Basically, I have the green stars, and I need the blue circles. 

Here's what I've tried, but I got lost. I'm not that great with math.
var leftBorder = (center) - (width / 2);
var rightBorder = (center) + (width / 2);
var topBorder = (center) - (height / 2);
var bottomBorder = (center) + (height / 2);

Here's what I came up with, however it's wrong.
BOTTOM_LEFT  { X: leftBorder  || Y: topBorder - leftBorder }
TOP_LEFT     { X: leftBorder  || Y: topBorder + leftBorder }
BOTTOM_RIGHT { X: rightBorder || Y: bottomBorder - rightBorder }
TOP_RIGHT    { X: rightBorder || Y: bottomBorder + rightBorder }

I'm at a complete loss of ideas.  

Given that $\textbf{a}_1=(a_{1,1},a_{1,2})$, $\textbf{a}_2=(a_{2,1},a_{2,2})$, $\textbf{a}_3=(a_{3,1},a_{3,2})$, and $\textbf{a}_4=(a_{4,1},a_{4,2})$ are the mid-points of the edges of a square in the Euclidean plane, the location of the vertices of the square can be determined as follows: 
Compute $r=|\textbf{a}_1-\textbf{a}_2|^2=(a_{1,1}-a_{2,1})^2+(a_{1,2}-a_{2,2})^2$
and $q=|\textbf{a}_1-\textbf{a}_3|^2=(a_{1,1}-a_{3,1})^2+(a_{1,2}-a_{3,2})^2$
If $r>q$ then the vertices (corners) of the square are 
$\textbf{v}_1=\textbf{a}_3+\frac{1}{2}(\textbf{a}_1-\textbf{a}_2)$,
$\textbf{v}_2=\textbf{a}_3-\frac{1}{2}(\textbf{a}_1-\textbf{a}_2)$,
$\textbf{v}_3=\textbf{a}_4+\frac{1}{2}(\textbf{a}_1-\textbf{a}_2)$, and
$\textbf{v}_4=\textbf{a}_4-\frac{1}{2}(\textbf{a}_1-\textbf{a}_2)$.
If $q>r$, then the vertices are
$\textbf{v}_1=\textbf{a}_2+\frac{1}{2}(\textbf{a}_1-\textbf{a}_3)$,
$\textbf{v}_2=\textbf{a}_2-\frac{1}{2}(\textbf{a}_1-\textbf{a}_3)$,
$\textbf{v}_3=\textbf{a}_4+\frac{1}{2}(\textbf{a}_1-\textbf{a}_3)$, and
$\textbf{v}_3=\textbf{a}_4-\frac{1}{2}(\textbf{a}_1-\textbf{a}_3)$.
I hope that helps! Please let me know if anything is unclear here. =)
