[Math] How to rotate a rectangle of latitude and longitude

geodesicgeometryrotations

I have a rectangle with its corners specified in latitude and longitude. I would like to rotate it about it's centre a certain number of degrees. I was using longitude as an x value and latitude as a y value but I realized that the rotation is actually on the surface of a sphere instead of a plane so might be inaccurate. Is there a formulate to do the rotation and give the new latitude and longitudes.

Best Answer

Your question really has nothing to do with “rectangles”, which @MPW has already pointed out don’t exist on a sphere. There is a way of looking at your problem that makes it an exercise in basic spherical trigonometry, and I’ll show you that. I do not make any claim that it’s the fastest way of getting your problem solved, though.

You have a point, let’s say $R$, on the sphere, let’s say it’s Richmond, and you want to rotate it about a fixed point $O$, let’s say that’s Orono. And your motion is a “rotation” in this sense: you have the “heading” $\alpha$ from $O$ to $R$, that is the compass-direction that you start out in if you’re going in a great-circle path. And you have the distance $d$ from $O$ to $R$. Your rotation asks for the location that you’ll get to if you go a distance of $d$ with an original heading of $\alpha+\delta$, where $\delta$ is the angle that you’re rotating things.

Now let’s draw a picture, you’ll have to do the drawing yourself. Knowing the latitude and longitude of Richmond and Orono, you see that there’s a triangle with vertex way up at the north pole $P$. The distance from $P$ to $O$ is Orono’s colatitude, that’s just the complement of Orono’s latitude. I’ll call this $c_O$. Similarly, you have the colatitude of Richmond, I’ll call this $c_R$. So you see that you have a triangle $RPO$ with legs $c_R$ and $c_O$, and up at the pole, the angle is the difference between the two cities’ longitudes. I’ll call this $\lambda$, to keep Greek letters for vertex angles and Latin lower-case for lengths of sides, capital letters for points on the sphere.

So you see that you have a SAS situation, and just as in plane trigonometry your first tool to use is Law of Cosines, to get the third side of your triangle, that’s the distance from $O$ to $R$, which I’ve called $d$. Then there’s also a spherical Law of Sines for getting the vertex angle $\alpha$ at $O=\,$Orono. The general Laws of Cosines and Sines are $$ \cos c=\cos a\cos b+\sin a\sin b\cos\gamma\,, $$ for Cosines, where $\gamma$ is the angle opposite the side of length $c$. And for the Law of Sines, $$ \frac{\sin a}{\sin\alpha}=\frac{\sin b}{\sin\beta}=\frac{\sin c}{\sin\gamma}\,, $$ where I’m sure you’ve guessed that $\beta$ is to be the angle opposite the side $b$ and $\alpha$ is the angle opposite the side $a$.

Now for our setup of rotating Richmond about the center Orono: We have our two legs $c_R$ and $c_O$ and our longitude-difference $\lambda$, so we get $$ \cos d = \cos c_R\cos c_O + \sin c_R\sin c_O\cos\lambda\,. $$ Now, with $d$ and $\lambda$ in hand, a side-and-opposite-angle pair, you can use Sines to get $\alpha$. Now add your rotation-angle $\delta$ to get $\alpha'=\alpha+\delta$, and to find your Richmond$'$, you use the triangle $POR'$, where $PO$ is still $c_O$, and $OR'$ is still $d$, but the known vertex angle now is at $O$, and it’s $\alpha'$. You see that it’s quite a megillah, but certainly very easily programmed.