# Calculate rotation on a sphere with given coordinates

I have a sphere with a fixed radius. I have a set of points on that sphere, let's say $p_1, p_2$ and $p_3$ and it's $3$D Cartesian coordinates.

I rotated each of the points around the center of the sphere with the rotation matrix $M$ and get the set of $p_{1r}, p_{2r}, p_{3r}$ cartesian coordinates.

How can I calculate the matrix $M$ if I know that points coordinates?

• This might not be the best way, but you can assume $M$ is some $3\times3$ matrix that when multiplied with a matrix with the columns of $p_1,p_2,p_3$, gives you a matrix with the columns of $p_{1r},p_{2r},p_{3r}$. That's $9$ equations for $9$ unknowns. Commented Sep 4, 2014 at 18:51
• @user137794 I recently found this approach en.wikipedia.org/wiki/Kabsch_algorithm what do you think can I use it? I am not a mathematician so can't be sure. But it looks very close to what I needed. Commented Sep 5, 2014 at 15:52

Rotations of sphere are linear transformations, so you can use formula from "Beginner's guide to mapping simplexes affinely", section "Linear transformations". Let's treat rotated points as vectors $$\vec{p}_{1r}$$, $$\vec{p}_{2r}$$, $$\vec{p}_{3r}$$, the answer can be written in the following neat form $$\vec{R}(p^x; p^y; p^z) = (-1) \frac{ \det \begin{pmatrix} 0 & \vec{p}_{1r} & \vec{p}_{2r} & \vec{p}_{3r} \\ p^x & p_1^x & p_2^x & p_3^x \\ p^y & p_1^y & p_2^y & p_3^y \\ p^z & p_1^z & p_2^z & p_3^z \\ \end{pmatrix} }{ \det \begin{pmatrix} p_1^x & p_2^x & p_3^x \\ p_1^y & p_2^y & p_3^y \\ p_1^z & p_2^z & p_3^z \\ \end{pmatrix} },$$ where upper indices designate components ($$x$$, $$y$$, $$z$$); $$p^x$$, $$p^y$$, and $$p^z$$ are coordinates of the point you are mapping. Expanding matrix in the numerator along the first column and rearranging everything you can get canonical form -- matrix times vector. General procedure of the matrix recovery is described in the "Beginner's guide to mapping simplexes affinely", section "canonical form", or you can check for concrete example in "Workbook on mapping simplexes affinely", section "Linear transformation by points".