How do I rotate a point on the surface of a sphere given 3 degrees of rotation?

165 Views Asked by At

I have a point on a sphere that needs to be rotated. I have 3 different degrees of rotation (roll, pitch, yaw). Are there any formulas I could use to calculate where the point would end up after applying each rotation? For simplicity's sake, the sphere can be centered on the origin if that helps.

I've tried looking at different ways of rotation, but nothing quite matches what I am looking for. If I needed to just rotate the sphere, I could do that, but I need to know the position of a point based on the rotation of the sphere.

If the original point is at (1, 0, 0), and the sphere then gets rotated by [45, 30, 15], what is the new (x, y, z) of the point?

2

There are 2 best solutions below

2
On BEST ANSWER

Rotation matrices are a useful tool in order to understand how to solve your problem. If you rotate your sphere with roll $\gamma$, pitch $\beta$ and yaw $\alpha$, this is equivalent to saying that every point $p$ on the original sphere gets mapped to a point $p_r$ on the rotated sphere defined as: $$ p_r = R_z(\alpha)R_y(\beta)R_x(\gamma)p, $$ where the basic rotation matrices $R_x$, $R_y$ and $R_z$ can be found here. Now, all you need to do is plug-in your numerical values for $\alpha$, $\beta$, $\gamma$ and $p$, and you'll obtain the rotated point.

(Here I'm considering that you perform roll, pitch and yaw in this order, but for any other ordering you can just swap the basic rotation matrices accordingly.)

Edit for additional details: I'm guessing you're not familiar with matrix multiplication. If you were to expand the formula above, and assuming that your initial point $p$ has coordinates $[p_x,p_y,p_z]$, the rotated point $p_r$ would be written as: $$ p_r = \begin{bmatrix} p_y \left(c_{\alpha } s_{\beta } s_{\gamma }-c_{\gamma } s_{\alpha}\right)+p_z \left(c_{\alpha } c_{\gamma } s_{\beta }+s_{\alpha } s_{\gamma}\right)+c_{\alpha } c_{\beta }p_x \\\\ c_{\beta } p_x s_{\alpha }+p_y\left(c_{\alpha } c_{\gamma }+s_{\alpha } s_{\beta } s_{\gamma }\right)+p_z\left(c_{\gamma } s_{\alpha } s_{\beta }-c_{\alpha } s_{\gamma}\right) \\\\ c_{\beta } p_y s_{\gamma }+c_{\beta } c_{\gamma } p_z-p_x s_{\beta}\end{bmatrix}, $$ where $c_\theta=\cos\theta$ and $s_\theta=\sin\theta$. As you can see this is quite a mouthful (in fact, I used a script to get this matrix). If you want to familiarize yourself with matrix multiplication, the Wikipedia page is a good place to start. Nevertheless, you can use the formula to directly compute the coordinates of the rotated point; plugging in your numerical values, you have: $$ p_r = \begin{bmatrix} \frac{1}{4} \sqrt{\frac{3}{2}} \left(1+\sqrt{3}\right)\\\\ \frac{1}{4}\sqrt{\frac{3}{2}} \left(\sqrt{3}-1\right)\\\\ -\frac{1}{2} \end{bmatrix} $$

2
On

I think there isn't anything stopping you from ignoring that the point is on a sphere and simply using matrix rotation as you would for any point in 3d space. If you center rotation on the origin the point will always stay "on the sphere" (ie. it will always be the same distance from the origin, 1 for your example point).

For matrix rotation, check out https://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions

Edit: To apply a rotation just mutiply the vector $\begin{bmatrix}x \cr y \cr z \end{bmatrix}$ by the corresponding matrix in the section, where $x,y,$ and $z$ represent your point's coordinates. For example, if you want to rotate a point with coordinates $\begin{bmatrix}1 \cr 0 \cr 0 \end{bmatrix}$ by ninety degrees in the yaw direction, plug in $\alpha = 90^\circ$ into the yaw matrix (make sure your calculator/programming language is in degree mode) and then multiply your vector with the resulting matrix in front (matrix multiplication is not commutative). You should get $\begin{bmatrix}0 \cr 1 \cr 0 \end{bmatrix}$. For matrix multiplication, check out https://www.mathsisfun.com/algebra/matrix-multiplying.html or use a calculator/programming language that provides it.