Seeking a closed-form solution of a system of nonlinear trigonometric equations (converting Euler angles to spherical)

96 Views Asked by At

Following this and this questions, I want to solve the system of nonlinear trigonometrical equations (as part of an inverse kinematics calculation):

$$\begin{align} \sin{\phi} \sin{\gamma} &= \sin\alpha \cos\theta_1 \cos\theta_2 + \cos\alpha \sin\theta_2\\ \cos{\phi} &= \cos\alpha \cos\theta_1 \cos\theta_2 - \sin\alpha \sin\theta_2 \\ \sin\phi \cos\gamma &= \sin\theta_1 \cos\theta_2 \end{align}$$

for $\theta_1$ and $\theta_2$ given the $\gamma$, $\phi$, and $\alpha$.

I think there should be closed form solution.

I tried Python-SymPy:

from sympy.solvers import solve
from sympy import symbols, sin, cos, tan

alpha, gamma, phi, theta1, theta2 = symbols('alpha gamma phi theta_1 theta_2')

eqs = (sin(alpha) * cos(theta1) + tan(theta2) * cos(alpha) - tan(gamma) * sin(theta1),
      cos(alpha) * cos(theta1) * cos(theta2) - sin(alpha) * sin(theta2) - cos(phi))
solve(eqs, (theta1, theta2))

However, the interpreter never finishes.

I would appreciate if you could help me know if the above system of equations has explicit solution.

2

There are 2 best solutions below

3
On

(too long for comment)

The Euler angles define the position of a 3D Euclidean reference system rotated wrt a base one.

The spherical coordinates define the position of one (unit vector), for instance the $x'$ axis of the rotated system: the position of the other two (rotation around $x'$) is not known.

So the correspondence is not univoque. You shall specify better what actually is your aim.

I saw now that you mention Rodrigues' formula: that is in fact relative to the rotation of a (unit) vector around another unit vector (axis of rotation). Practically the rotation of a point on earth around another point on earth. So how is your problem formulated in this "environment" ?

From your self-answer, and taking as reference the Geographic convention for Spherical Coordinates with $\theta_1$ as longitude and $\theta_2$ as latitude, it is now clear that you want to
- take a vector in such a reference system $$ {\bf v} =\left( {1,\theta _1 ,\theta _2 } \right) = \left( {\matrix{ {\cos \theta _2 \cos \theta _1 } \cr {\cos \theta _2 \sin \theta _1 } \cr {\sin \theta _2 } \cr } } \right) $$ - exchange its components according to the matrix $$ {\bf E} = \left( {\matrix{ 0 & 0 & 1 \cr 1 & 0 & 0 \cr 0 & 1 & 0 \cr } } \right) $$ which has a negative determinant and so includes a reflection;
- rotate it around the original reference polar axis ($z$) of an angle $- \alpha$ (in the right-hand convention, i.e. eastward) $$ {\bf R}_{\,{\bf z}} ( - \alpha ) = \left( {\matrix{ {\cos \alpha } & { + \sin \alpha } & 0 \cr { - \sin \alpha } & {\cos \alpha } & 0 \cr 0 & 0 & 1 \cr } } \right) $$ - exchange back its components $$ {\bf E}^{\, - \,{\bf 1}} = \left( {\matrix{ 0 & 1 & 0 \cr 0 & 0 & 1 \cr 1 & 0 & 0 \cr } } \right) $$ - rename the resulting longitude ${\theta '}_1$ as $\gamma$, and take the azimut angle $\phi$ in place of the resulting latitude ${\theta '}_2$ , i.e. $\phi = \pi/2-{\theta '}_2$.

Is that your goal?

0
On

Thanks to the great comment by achille hui we can write the system of equations as:

$$ \begin{bmatrix} \sin \phi \sin\gamma \\ \cos \phi\\ \sin \phi \cos\gamma \end{bmatrix} = R(\alpha) \begin{bmatrix} \sin\theta_2\\ \cos\theta_1 \cos\theta_2\\ \sin\theta_1 \cos\theta_2 \end{bmatrix} $$

where $R(\alpha)$ is the rotation matrix of:

$$ R(\alpha) =\begin{bmatrix} \cos\alpha & \sin\alpha & 0\\ -\sin\alpha & \cos\alpha & 0\\ 0 & 0 & 1\\ \end{bmatrix} $$

and its invert is

$$ R^{-1}(\alpha) = R(-\alpha) = \begin{bmatrix} \cos\alpha & -\sin\alpha & 0\\ \sin\alpha & \cos\alpha & 0\\ 0 & 0 & 1\\ \end{bmatrix} $$

now the equation can be rewritten as:

$$ \begin{bmatrix} \sin\theta_2\\ \cos\theta_1 \cos\theta_2\\ \sin\theta_1 \cos\theta_2 \end{bmatrix} = \displaystyle \left[\begin{matrix}- \sin{\left(\alpha \right)} \cos{\left(\phi \right)} + \sin{\left(\gamma \right)} \sin{\left(\phi \right)} \cos{\left(\alpha \right)}\\\sin{\left(\alpha \right)} \sin{\left(\gamma \right)} \sin{\left(\phi \right)} + \cos{\left(\alpha \right)} \cos{\left(\phi \right)}\\\sin{\left(\phi \right)} \cos{\left(\gamma \right)}\end{matrix}\right] $$

which is calculated through the python-sympy command of

Matrix([[cos(alpha), -sin(alpha), 0],
       [sin(alpha), cos(alpha), 0],
       [0, 0, 1]]) * Matrix([[sin(phi) * sin(gamma)], [cos(phi)], [sin(phi) * cos(gamma)]])

and as a result we get:

$$\tan{\theta_1} = \frac{\sin{\phi} \cos{\gamma}}{\sin{\alpha} \sin{\gamma} \sin{\phi} + \cos{\alpha} \cos{\phi}}$$

and

$$ \sin{\theta_2} = \sin{\left(\gamma \right)} \sin{\left(\phi \right)} \cos{\left(\alpha \right)} - \sin{\left(\alpha \right)} \cos{\left(\phi \right)} $$