How to find corners of square from it's center point?
It's has been a while since I used any basic trigonometry, so I'm here requesting some aiding. I have the center point of a square (as lng/lat pair which I believe I can use as x/y) and the side length, and I need to find all 4 corners coordinates from this origin.
How can I achieve this please?
$\endgroup$ 23 Answers
$\begingroup$Assuming the length of the square is L, I hope the drawing below answers your question. I called the center point c, and each corner p1,p2,p3 and p4.
$\endgroup$ 4 $\begingroup$Let L = length of side. Let (h,k) be the center point.
The simplest answer is $(h + \frac 1 2 L, k + \frac 1 2 L), (h + \frac 1 2 L, k - \frac 1 2 L),(h - \frac 1 2 L, k - \frac 1 2 L), (h - \frac 1 2 L, k + \frac 1 2 L)$
If the square must be rotated by the angle $\theta$, The the solutions are $(h + \frac 1 2 L \sin \theta, k + \frac 1 2 L \cos \theta), (h - \frac 1 2 L \cos \theta, k + \frac 1 2 L \sin \theta),(h - \frac 1 2 L \sin \theta, k - \frac 1 2 L \cos \theta), (h + \frac 1 2 L \cos \theta, k - \frac 1 2 L \sin \theta)$
$\endgroup$ $\begingroup$In case the square is rotated around the center by an angle theta, w.r.t the ground position (considered as when the sides are parallel to the $x$ and $y$ axis), the vertices are given as -
Let $L =$ length of the side. Let $(h,k)$ be the center point.
$(h - \frac{1}{2}L(\sin\theta + \cos\theta), k - \frac{1}{2}L(\sin\theta - \cos\theta)$,$(h + \frac{1}{2}L(\sin\theta - \cos\theta), k - \frac{1}{2}L(\sin\theta + \cos\theta)$,$(h + \frac{1}{2}L(\sin\theta + \cos\theta), k + \frac{1}{2}L(\sin\theta - \cos\theta)$,$(h - \frac{1}{2}L(\sin\theta - \cos\theta), k + \frac{1}{2}L(\sin\theta + \cos\theta)$
Please beware, the answer provided by @fleablood seems to be wrong. Didn't work out for me. It fails in the very basic case of $\theta=0$ and $\theta=90^\circ$ or I'm misinterpreting the answer provided.
$\endgroup$ 1