1
$\begingroup$

I have a unit sphere with points on its surface described by their azimuth and elevation. Azimuth is given as a number in $[0, 2 \pi]$, while elevation is a between $[-\pi/2, \pi/2]$.

I would like to rotate the sphere on the elevation axis (rotating by azimuth is trivial). For example, I'd rotate the sphere by $\pi / 2$ at azimuth 0, meaning that any point at azimuth 0 will be "elevated" by $\pi / 2$, while points on other azimuths will be elevated by a different amount depending on how far they are from the pivot point.

On the other side of the azimuth, at $\pi$, each point would be pushed down by $\pi / 2$.

What I'm after is the transformation formula for any point on the surface, for a given elevation angle and azimuth pivot point.

I'm having trouble working out the math for this. I have a version but I get false results. I'd really appreciate some help.

$\endgroup$
2
  • 1
    $\begingroup$ Are your elevation and azimuth analogous to latitude and longitude on Earth? $\endgroup$ – Nominal Animal Feb 22 '18 at 4:10
  • $\begingroup$ Yeah, it's a pretty similar concept. $\endgroup$ – gphilip Feb 22 '18 at 12:42
2
+50
$\begingroup$

It is very easy to compute this rotation in a 3D cartesian coordinate system on the 2-sphere $\Bbb S^2$, simply by applying a certain rotation matrix. But it is tricky to do this in your azimuth/elevation system on $[0,2\pi]\times[-\pi/2,\pi/2]$.

I therefore recommend convert between these systems. How this can be done in detail is well-explained on the Wikipedia article on sphereical coordinate systems.

So I assume we have

  • A conversion from spherical into cartesian: $f:(\phi,\theta)\mapsto(x,y,z)$.
  • A conversion from cartesian into spherical: $g:(x,y,z)\mapsto(\phi,\theta)$.
  • A rotation around azimuth by $\Delta\phi$: $h_{\Delta\phi}(\phi,\theta)=(\phi+\Delta\phi,\theta)$.
  • A rotation matrix for rotation around the the $y$-axis by an angle of $\theta$ in cartesian coordinates: $$R_\theta=\begin{pmatrix}\cos(\theta)&0&-\sin(\theta)\\0&0&0\\\sin(\theta)&0&\cos(\theta)\end{pmatrix}.$$

I assume that $f(0,0)=(1,0,0)$ is mapped to the positive $x$-axis, and $f(\pi/2,0)=(0,1,0)$ is mapped to the positive $y$-axis. This means that elevation describes the rotation out of the $xy$-plane.

Now, let's say you want to rotatate around elevation by an angle of $\Delta\theta$ at azimuth $\phi_0$. This can be done by the following transformation:

$$h_{\phi_0}\circ g\circ R_{\Delta\theta}\circ f\circ h_{-\phi_0}\quad:\quad (\phi,\theta)\quad\mapsto\quad h_{\phi_0}(g(R_{\Delta\theta}f(h_{-\phi_0}(\phi,\theta)))).$$

It is not a nice formula, but it works. One might write this out as a single formula, but it will probably be long and ugly.

$\endgroup$
1
  • $\begingroup$ Thanks for that! I really want to avoid the conversion to 3D coordinate system, it makes no sense to me to do that. It adds a lot of unnecessary complexity. $\endgroup$ – gphilip Feb 22 '18 at 9:09
0
$\begingroup$

I should think quaternions would work well for your problem. As you see on the wiki, given a vector $\mathbf{p}$ and axis of rotation $\mathbf{u}$, a unit vector, and angle $\theta$ through which to rotate, you form the rotation quaternion as $$q=\cos(\theta/2)+(u_x\mathbf{i}+u_y\mathbf{j}+u_z\mathbf{k})\sin(\theta/2),$$ and the vector extension into quaternions as $$p=0+p_x\mathbf{i}+p_y\mathbf{j}+p_z\mathbf{k}.$$ You do the rotation by $p'=qpq^{-1}$, and the inverse $q^{-1}$ you can find simply by "conjugating" the $q$ quaternion. The quaternion multiplication is what William Rowan Hamilton discovered, and I would totally do that in a computer software package, as it's a lot of multiplication, addition, and subtraction.

The advantage of quaternions is that you avoid gymbal lock, and the representation of a quaternion is relatively efficient. It also allows you to rotate about any axis whatever, unlike Euler rotation matrices. You have to extend Euler matrices as illustrated here to do that.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.