You are given the linear trigonometric system of equations described by:
$ a_1 \cos(x) + a_2 \cos(y) + a_3 \cos(z) + a_4 \sin(x) + a_5 \sin(y) + a_6 \sin(z) = d \tag{1} $
$ b_1 \cos(x) + b_2 \cos(y) + b_3 \cos(z) + b_4 \sin(x) + b_5 \sin(y) + b_6 \sin(z) = e \tag{2} $
$ c_1 \cos(x) + c_2 \cos(y) + c_3 \cos(z) + c_4 \sin(x) + c_5 \sin(y) + c_6 \sin(z) = f \tag{3}$
where $a_i, b_i, c_i, i = 1, 2, \dots 6 \in \mathbb{R} $ and $ d,e,f \in \mathbb{R} $ are known. The unknowns are $x,y,z$. It is assumed that $x,y,z \in [-\pi, \pi) $.
I want to solve this system for the angles $x,y,z$.
My Attempt:
Define the vector of unknowns as
$ X = \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ x_4 \\ x_5 \\ x_6 \end{bmatrix} = \begin{bmatrix} \cos(x) \\ \sin(x) \\ \cos(y) \\ \sin(y) \\ \cos(z) \\ \sin(z) \end{bmatrix} \tag{4}$
And the matrix
$ A = \begin{bmatrix} a_1 && a_4 && a_2 && a_5 && a_3 && a_6 \\ b_1 && b_4 && b_2 && b_5 && b_3 && b_6 \\ c_1 && c_4 && c_2 && c_5 && c_3 && c_6 \end{bmatrix} \tag{5} $
$ B = \begin{bmatrix} d \\ e \\ f \end{bmatrix} \tag{6}$
Then our system can be written as follows:
$ A X = B \tag{7} $
together with
$ x_1^2 + x_2^2 = 1 \tag{8} $
$ x_3^2 + x_4^2 = 1 \tag{9}$
$ x_5^2 + x_6^2 = 1 \tag{10}$
The first step is to to solve the system $A X = B$. Since a non-homogenous linear system of $3$ equations in $6$ unknowns, the solution will be of the form
$ X = X_0 + C u = H w \tag{11}$
where $X_0 \in \mathbb{R}^6 $ is known , $C \in \mathbb{R}^{6 \times 3 }$ is known, and $ u =[u_1, u_2, u_3]^T \in \mathbb{R}^3 $ is a vector of free parameters. The value of these parameters will be determined from the additional constraints. Defining $w = [u_1, u_2, u_3, 1]^T \in \mathbb{R}^4$, and $H = [ C , X_0] $ gives the above-mentioned equality.
The three given constraints can be written as
$ X^T Q_1 X = 1 $ , $ X^T Q_2 X = 1 $, $ X^T Q_3 X = 1 $
where $Q_1$ has all entries equal to $0$ except the $(1,1)$ and $(2,2)$ entries which are set to $1$.
Similarly $Q_2$ has all entries equal to $0$ except the $(3,3)$ and $(4,4)$ entries which are set to $1$.
And lastly, $Q_3$ has all entries equal to $0$ except the $(5,5)$ and $(6,6)$ entries which are set to $1$.
Since $X = H w $, then we now have the quadratic system of $3$ equations:
$ w^T H^T Q_1 H w = 1 \tag{12a}$
$ w^T H^T Q_2 H w = 1 \tag{12b}$
$ w^T H^T Q_3 H w = 1 \tag{12c}$
$ e_4^T w = 1 \tag{12d}$
where $e_4 = [0,0,0,1]^T $
This system of equations can be solved by a CAS (Computer Algebra System) such as Mathematica, Maple, Sage, etc. There can anywhere from $0$ to $8$ solutions. I did not use any of the online CAS systems. Instead I used a solver for 3 quadratic equations in 3 unknowns that I have developed myself. This problem is addressed in this MSE question and its answer here.
This is a link to the Excel file that contains the source code for the function "intersect_three_quadrics" which solves a system of three quadratic equations in three unknowns, and also other functions that solve a system of two quadratic equations in two unknowns. These are included in this file as macros (VBA script). Click on the link, to open the online file, then click on "Editing" and choose "Open in Desktop App". This will open the file in your desktop Excel program. Click "View" then select "Macros". You can copy the code in this Excel file to a new file and call the solver function "intersect_three_quadrics" from your own VBA code.
Once the unknown $w$ is determined, the $\cos$'s and $\sin$'s of $x,y,z$ vector $X$ can be determined from $X = H w $. And finally the angles $x,y,z$ can be determined using the $\text{Atan2}$ function.
Using my own developed solver, I've written code to test this method, and found that the method works.
An example that I worked on had
$ A = \begin{bmatrix} 16 && 10 && -2.333 && 1.25 && 3.05 && -4.6 \\ 4.05 && 3.9 && -2.2 && 2.6 && 1.15 && 1.95 \\ -3.45 && 5.56 && 6.7 && 4.33 && -5.22 && 13.09 \end{bmatrix} $
and
$ B = \begin{bmatrix} 10 \\ 4 \\ 1 \end{bmatrix} $
The program that I wrote produced $8$ different solutions for $(x,y,z)$, and they are
$ (1.547467576, -2.877830759, -2.985325265) $
$ (1.780814629, 1.976638042, -2.283527333) $
$ (-0.513523632, 0.903408232, 0.321838196) $
$ (-0.160877144, -1.984485011, 1.392156825) $
$ (-0.403278317, 1.857437471, -3.057060696)$
$ (1.572308788, -1.873139221, 0.490617376) $
$ (1.888904049, 1.228551222, -0.598486629) $
$ (-0.133717443, -2.410921989, 2.33919753 ) $
That's all I could come up with. Your comments and alternative solutions are appreciated.
can be reduced to
$$ \sqrt{a_1^2+a_2^2}\cos(x-x_0)+\sqrt{a_3^2+a_4^2}\cos(y-y_0)+\sqrt{a_5^2+a_6^2}\cos(z-z_0) = d $$
with $x_0 = \arctan(a_1,a_2)$ etc.
– Cesareo Sep 12 '24 at 16:09