[Math] Rotating a sphere

geometryrotationsspheresspherical trigonometrytrigonometry

I'm trying to rotate a sphere, and I'm having a bit of a problem calculating the angle to rotate it by. I wonder if anyone can help me?

On my sphere I've marked three points. If the centre of the sphere is (0,0,0), then the points are where the x, y and z axis exit the sphere.

For example:

sphere unrotated

What I would like to do, is rotate the sphere so that an axis (lets say the z axis) exits the sphere such that these three points are all exactly the same distance from the z axis.

For example, the z axis would exit the sphere approximately here:

Desired Location of z axis

This is what I've got so far.

First I rotate the sphere by 45 degrees around the x axis:

sphere rotated around the x axis

So far, no problem.

I then rotate the sphere by -45 degrees around the y axis.

At first glance, it appears to have worked:

nearly worked

But if I enlarge the circles marked on the sphere, it's obvious that the z axis is not exiting the sphere at the right point:

Not Exiting the sphere at the right point

Now I've done a bit of experimenting, and if I rotate the sphere by -35.1, not -45 degrees around the y axis, then it is roughly in the right position.

I've spent the afternoon with pen and paper trying to figure out what I should be rotating by, but I just can't figure the exact angle to rotate by.

Note: the application for this, is I'm trying to design a small stand to be 3d printed. I would like the stand to be exactly level.

If anyone can help, it'd be much appreciated!

Thanks in advance!

David.

Best Answer

You can use the well-known Rodriguez rotation formula (https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula), which states

$ \textbf{v}' = \textbf{v}\cos\theta + (\textbf{r}\times\textbf{v})\sin\theta + \textbf{r}(\textbf{v}\cdot\textbf{r})(1-\cos\theta) $

where $\textbf{v}$ is the original vector, $\textbf{r}$ is the vector about which the rotation on angle $\theta$ is performed, and $\textbf{v}'$ is the vector after rotation.

Now, by applying this formula twice (first, for example, for the rotation on angle $\alpha$ about $x-$axis and then on angle $\beta$ around $y-$axis), we get

$\textbf{k}'' = \textbf{i}\cos\alpha\sin\beta -\textbf{j}\sin\alpha + \textbf{k}\cos\alpha\cos\beta$.

Now, to find the angle between $\textbf{k}$ and $\textbf{k}''$, you can take the dot-product of them

$\cos \angle(\textbf{k},\textbf{k}'') = \textbf{k}\cdot\textbf{k}'' = \cos\alpha\cos\beta$.

Alternatively, the same can be found as (suggested by Jonas above)

$\cos \angle(\textbf{k},\textbf{k}'') = \langle (0,0,1),(1,1,1)\rangle/\sqrt{3} = \frac{1}{\sqrt{3}}$.

Now, let consider specific example of $\alpha = 45^\circ$ and $\beta = X^\circ$. So, we have

$\frac{\sqrt{2}}{2}\cos X = \frac{1}{\sqrt{3}}$,

from where $X =\cos^{-1}\sqrt{\frac{2}{3}} \approx 35.2644^\circ$.

You were close when you experimented with angles.

Hope this helps.

Related Question