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.  
 A: 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. =)
A: If the square is axis aligned, the $y$ coordinates are the $\max$ and $\min$ of the $y$ coordinates of your stars and similarly for your $x$'s.  Take the four combinations and you are done.  I don' read the language you are using.  What is $||$ as an operator?
A: Is the length of the square known?

Assuming it is and taking it to be s, coordinates of centre of square to be (x,y) we have co-ordinates of the green corners:

1. left border:   (x-s/2,y)
2. right border:  (x+s/2,y)
from these, you can easily get the coordinates of the corners:

1. north west corner: (x-s/2,y) + (0,s/2) = (x-s/2,y+s/2) 
[adding s/2 to y coordinate of centre point of left border]

2. north east corner: (x+s/2,y) + (0,s/2) = (x+s/2,y+s/2) 
[adding s/2 to y coordinate of centre point of right border]

3. south west corner: (x-s/2,y) + (0,-s/2) = (x-s/2,y-s/2) 
[subtracting s/2 from y coordinate of centre point of left border]

4. south east corner: (x+s/2,y) + (0,-s/2) = (x+s/2,y-s/2) 
[subtracting s/2 from y coordinate of centre point of right border]
